Wednesday, June 7, 2017

Thrift fails on Windows - thrift failed error: The command line is too long.

Meet a thrift compiling failure on my project on Windows 7. Using Maven in IntelliJ so I choiced maven-thrift-pluging for thrift files. For one project, the thrift failed as below:

[INFO] — maven-thrift-plugin:0.1.11:compile (thrift-sources) @ xxxxxxxxxxxxxxx —
[ERROR] thrift failed output: 
[ERROR] thrift failed error: The command line is too long.

Executed the thrift --gen manually did not meet this issue, so most likely caused by how maven-thrift-plugin call the compiler. Finally I had a workaround to decrease the thrift temp file folder path to pass the build:

Below configuration changed the folder name from default "thrift-dependencies" to "td", lucky my project pass build, otherwise I think I have to move my project to a up-level folder to get a shorter path.

<plugin>    <groupId>org.apache.thrift.tools</groupId>    <artifactId>maven-thrift-plugin</artifactId>    <configuration>        <thriftExecutable>${thrift.compiler}</thriftExecutable>        <generator>${thrift.generator}</generator>        <temporaryThriftFileDirectory>${project.build.directory}/td</temporaryThriftFileDirectory>    </configuration></plugin>

Friday, May 5, 2017

Gradle Failed for Google Guava: transformClassesWithDexForDebug TransformException

Meet the compile issue when adding Google Guava into my Android project:

dependencies {
  compile 'com.google.guava:guava:21.0'
}
Error:

10:16:43.803 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > com.android.build.api.transform.TransformException: com.android.ide.common.pro
cess.ProcessException: Error while executing java process with main class com.android.multidex.ClassReferenceListBuilder with arguments {xxxxxxxxxxx\build\intermediates\multi-dex\debug\componentClasses.jar xxxxxxxxx\build\intermediates\transforms\jarMerging\de
bug\jars\1\1f\combined.jar}

After downgrade guava to version 19 the project passed build successfully:
dependencies {
  compile 'com.google.guava:guava:19.0'
}
Have no time to dig into the root cause yet, record here for reference.

Wednesday, March 8, 2017

How to build React-Native behind proxy

Recently I tried to setup and build react-native app (mostly for Android), behind a proxy server. To pass the gradle build, need set proxy config as below:


  • Edit AwesomeProject\Android\gradle.properties, add proxy config:
  •     systemProp.http.proxyHost=10.255.247.227
  •     systemProp.http.proxyPort=8080
  •     systemProp.https.proxyHost=10.255.247.227
  •     systemProp.https.proxyPort=8080


Thursday, May 5, 2016

error: undefined reference to '__android_log_print' in Android Studio 2.1

Need load the android log lib in app/build.gradle:

    android.ndk {
        moduleName = "[the_module_name]"
        ldLibs.addAll(['android', 'log'])
    }

Thursday, January 29, 2015

Make TextView scrollable without using ScrollView

2 steps, firstly, set scroll bar rotation in AndroidManifest.xml:
         android:scrollbars="vertical"

Then, set the scrolling method for the TextView, mostly in onCreate() function:
        ((TextView)findViewById(R.id.textview)).setMovementMethod(ScrollingMovementMethod.getInstance());

Parent Activity is destroyed when providing Up navigation

If providing Up navigation behavior as Android doc: http://developer.android.com/training/implementing-navigation/ancestral.html, when click the Up button on the navigation bar, the parent activity is destroyed then re-created. It is different behavior as pressing back key.

To avoid destroy parent activity, one solution is setting launch mode <singleTop> for the activity in AndroidManifest.xml:
android:launchMode="singleTop"

The different between Up key and Back key is, when pressing Back key, by default, the currently activity is popup from activity stack and finished, so the previously activity shows up. When pressing Up key, the currently activity is popup from stack too, but the parent activity, which is defined in AndroidManifest.xml and maybe not the previously activity, is created to show. By default the launch mode is <standard> so the existed activity task is destroyed then re-create. To set the launch mode to <singleTop>, Android will launch the existed one instead of create a new task.

Tuesday, October 28, 2014

Get Android Kernel log

 To catch Kernel log, need a rooted Android device and adb shell worable, then use the adb logcat command:

$adb shell logcat -v time -f /dev/kmsg | cat /proc/kmsg

To  write the output to a file:
$adb shell logcat -v time -f /dev/kmsg | cat /proc/kmsg > /sdcard/log.txt

Thrift fails on Windows - thrift failed error: The command line is too long.

Meet a thrift compiling failure on my project on Windows 7. Using Maven in IntelliJ so I choiced maven-thrift-pluging for thrift files. For ...