rosjava / android_core

Android libraries for rosjava
146 stars 166 forks source link

Can't build project in Android Studio 0.5.1 #198

Closed DmitryDzz closed 10 years ago

DmitryDzz commented 10 years ago

It worked before but I can't build the project (Hydro branch) since I updated Android Studio to 0.5.1. I cloned the repository, then I switched to Hydro branch. "./gradlew assemble" worked fine but when I tried to build the project in Android Studio it said:

12:29:20 PM Failed to refresh Gradle project 'android_core' The project is using an unsupported version of the Android Gradle plug-in (0.7.1). Version 0.9.0 introduced incompatible changes in the build language. Please read the migration guide to learn how to update your project. Open migration guide, fix plug-in version and re-import project

I tried different ways: Gradle 1.9, 1.10, 1.11, I changed "gradle-wrapper.properties", even added:

buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.9.+' } } to all android_core projects. That doesn't help.

ollide commented 10 years ago

Adding the Android Gradle Plugin dependency manually to all android_core subprojects will not help, because this plugin dependency is already defined transitively in the RosAndroidPlugin (ros-android) in rosjava_bootstrap (see line 29 in the source code).

So to build android_core using latest Android Gradle Plugin & Android Studio, you need to update RosAndroid.groovy and compile rosjava locally again. It may be required to bump all gradle version references in rosjava subprojects to 1.11 (or 1.10 as it's also supported in 0.9.+) to compile rosjava_core.

### RosAndroid.groovy diff
-        classpath 'com.android.tools.build:gradle:0.7.1'
+        classpath 'com.android.tools.build:gradle:0.9.+'

After rosjava was successfully compiled, bump the gradle wrapper in android_core/build.gradle and android_core/gradle/wrapper/gradle-wrapper.properties to 1.10/1.11 and get coding! :)

DmitryDzz commented 10 years ago

ollide, thank you for your kind reply. I'm new in ROS and Gradle concepts. So I think I've lost something. As you said I successfully updated, rebuilt and installed rosjava_bootstrap and rosjava_core ("./gradlew wrapper assemble install"). I sent pull requests, may be it's time to change gradle version in these projects.

But when I tried to rebuild android_core I faced the same error:

./gradlew assemble
:android_acm_serial:compileLint
:android_acm_serial:copyDebugLint UP-TO-DATE
:android_acm_serial:mergeDebugProguardFiles UP-TO-DATE
:android_acm_serial:packageDebugAidl UP-TO-DATE
:android_acm_serial:preBuild FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':android_acm_serial:preBuild'.
> Build Tools Revision 19.0.0+ is required.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 10.931 secs

And this is my updated .../android_acm_serial/build.gradle:

buildscript {
  repositories {
    mavenCentral()
  }

  dependencies {
    classpath 'com.android.tools.build:gradle:0.9.+'
  }
}

dependencies {
  compile project(':android_honeycomb_mr2')
  compile project(':android_gingerbread_mr1')
}

apply plugin: 'android-library'

android {
    compileSdkVersion 13
    buildToolsVersion '19.0.3'
}
DmitryDzz commented 10 years ago

ollide, thank you very much for your help! That's it: I missed buildToolsVersion '19.0.3'. I rebuild everything and now I can compile my project in command line and in Android Studio. I made pull request with the update.

stonier commented 10 years ago

Have you tried setting the buildToolsVersion to 19.0.3 in RosAndroid.groovy? I think the version is applied to the android (sub)projects.

The build tools version is set centrally in RosAndroid.groovy to save having to redundantly update groovy code in many repos at once very frequently. Instead of modifying the groovy file itself you can just run android and install the 18.1.1 version (this is actually mentioned on the roswiki download instructions). If you have a reason you need the latest tools, post an issue/pull request here and we can update them.

stonier commented 10 years ago

Also added a FAQ page on the roswiki addressing this.