Building ROS android_sensors_driver Gradle - android

I'm having issues building a project with gradle on Ubuntu 14.04. The project in particular is the ROS android_sensors_driver project. I get a build error after executing gradlew clean debug. The offending line is compile project(':android-15') . I think that it is looking for the android-15 platform in the SDK. I have set ANDROID_HOME to the directory where the SDK is located. The project was cloned from here. The build.gradle file is.
dependencies {
compile "org.ros.rosjava_core:rosjava:0.2.0"
compile "org.ros.rosjava_core:rosjava_tutorial_pubsub:[0,)"
compile 'com.android.support:support-v4:21.0.0'
compile project(':android-15')
}
apply plugin: 'android'
/*debug.dependsOn project(':android_gingerbread_mr1').tasks.debug*/
android {
compileSdkVersion 15
defaultConfig {
minSdkVersion 15
applicationId "org.ros.android.android_sensor_driver"
targetSdkVersion 15
versionCode 1
versionName "1.0"
}
}
Any ideas what the issue might be. Let me know what extra info you might need. I'm reasonably new to linux and gradle?
Thanks

the compiler are saying that the class android has no function android() that receive the parameters are you passing:
MissingMethodException: Could not find method android() for arguments
Check if the arguments that you are sending to the method are the same needed and if the class has some function overloading to a method that receive these arguments you are giving.
I hope it help!

Related

Debugging C++/native library modules not working with Android Studio (Cmake used)

I'm having trouble debugging C++ files of my library module.
Is this possible in general?
The debugging works fine if the application project contains the c++ code.
But I want to move the C++ Code to a library module.
The Error Message while starting the session:
Now Launching Native Debug Session
Attention! No symbol directories found - please check your native debug configuration
gradle file of my lib:
apply plugin: 'com.android.library'
android {
compileSdkVersion 24
buildToolsVersion "25.0.2"
defaultConfig {
minSdkVersion 16
targetSdkVersion 21
versionCode 1
versionName "1.0"
externalNativeBuild {
cmake {
arguments "-DANDROID_PLATFORM_LEVEL=${11}",
'-DANDROID_TOOLCHAIN=clang', '-DANDROID_STL=gnustl_static'
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
externalNativeBuild {
cmake {
path "CMakeLists.txt"
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-annotations:24.2.0'
}
In the run configuration the debugger is set to auto
Additions:
Im using:
Gradle : 2.2.3
Android Studio : 2.2.3
in the LLLB Console, i checked the breakpoint List with:
breakpoint list -v
all my checkpoints are listed there.
Not Working Breakpoint
1: file = 'C:\android-dev\...\test.cpp', line = 19, exact_match = 0
..thats all
Working Breakpoint
1: file = 'C:\android-dev\...\test.cpp', line = 19, exact_match = 0
1.1:
module = C:\android-dev\...\test.so
compile unit = gl_code.cpp
function = testFunc(..)
location = C:\android-dev\...\test.cpp:16
address = 0x0000007f871d068c
resolved = true
hit count = 1
The reason seems to be, that a release version of the lib is created,
which does not support debugging, even if the app is built with debug options.
Solution:
To solve this issue, do the following workaround. It ensures that a debug version is built.
In your apps build.gradle change:
compile project(':nativelib')
to
compile project(path: ':nativelib' , configuration: 'debug')
In the libs build.gradle add:
android {
publishNonDefault true //this line
compileSdkVersion 24
buildToolsVersion "25.0.2"
defaultConfig {
...
}
...
}
Updates:
See the google issue for updates:
https://code.google.com/p/android/issues/detail?id=222276
I had the same error ("Attention! No symbol directories found - please check your native debug configuration."). My solution was (Android Studio 3.2):
Run → Edit Configuration → "Debugger" tab → add your working path to Symbol Directories.
I had the similar issue with my own libraries some months ago because I thought that if I added the -g (gcc) flag it would generate the debug symbols, as the desktop (linux, unix kernel) apps.
But, actually it does not work to generate debug symbols.
I see that you use Cmake as a external build tool and clang compiler.
So in my case I configure my cmake script with gcc but out of gradle scripting, but I think it will be the same, I add -mapcs-frame in the CMAKE_CXX_FLAGS.
externalNativeBuild {
cmake {
arguments "-DANDROID_PLATFORM_LEVEL=${11}",
'-DANDROID_TOOLCHAIN=gcc',
'-DANDROID_STL=gnustl_static',
'DCMAKE_CXX_FLAGS=-mapcs-frame'
}
}
I know that if you use clang compile may be this flag could not work. But my idea was to share my experience with android native debugging.
I Hope this clues could help you.
Cheers.
Unai.
In my case, it was because of co-worker who changed the visibility of symbols.
set(CMAKE_CXX_FLAGS -fvisibility=hidden)
After changing the above code to be applied only in release build, debugger(including breakpoints) works fine.

Dagger 2 : Cannot resolve symbol for dagger component

I would like to exercise this Dagger 2 Vehicle Motor example.
I made everything exact like in that tutorial, except for my gradel.build:
compile 'com.google.dagger:dagger:2.4'
apt 'com.google.dagger:dagger-compiler:2.4'
compile 'javax.annotation:javax.annotation-api:1.2'
but then I get an
error: cannot find symbol variable Dagger_VehicleComponent
Whats wrong there? (Same without '_' underscore)
Another version solved it:
compile 'com.google.dagger:dagger:2.2'
apt 'com.google.dagger:dagger-compiler:2.2'
provided 'javax.annotation:jsr250-api:1.0'
Change Dagger_VehicleComponent with DaggerVehicleComponent
Clean and rebuild your project
Import DaggerVehicleComponent class
Took me a while to figure this out. But I found the reason (At least on my side)
I created a project from scratch, after that I was trying to set up the basic components/tools till I bump into this issue.
Reading other answers I found that DaggerApplicationComponent class is autogenerated by the compiler, then I thought, why the IDE can't "find" this class?
The answer is obvious and... you got it, was because the project wasn't compiling, here are the steps to solve this issue if the scenario is the same as mine.
1) Open terminal and go to your projects path (Or simply open the terminal in the Android Studio)
2) Clean project
./gradlew clean
3) Build the project
./gradlew build
NOTE: If by this point you have noticed the project is not compiling... Bingo! That might be the real issue. Then follow the next steps:
4)Open gradle and add the buildToolsVersion '23.0.1' and very IMPORTANT has to be enabled multiDexEnabled true
This is how my gradle in the app module looks like
android {
buildToolsVersion '23.0.1' // IMPORTANT
compileSdkVersion 26
defaultConfig {
applicationId "com.fixing.dagger"
minSdkVersion 23
targetSdkVersion 26
versionCode 1
versionName "1.0"
multiDexEnabled true // ALSO IMPORTANT
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
After that you will be able to import the DaggerApplicationComponent.
Hope this saves time for someone else!

Android Studio Gradle Error - preDexDebug

I recently added a new activity to my android studio project and now I am getting an error when I try and run it. It builds fine but I get the error below when I run it:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:preDexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
/Applications/Android Studio.app/sdk/build-tools/android-4.4W/dx --dex --output /Users/davidcavanagh/joshcpdandroid/app/build/intermediates/pre-dexed/debug/classes-22ecb8c50fefe43948d87c9fee8e36a6b7d1bb5a.jar /Users/davidcavanagh/joshcpdandroid/app/build/intermediates/exploded-aar/com.android.support/support-v4/20.0.0/classes.jar
Error Code:
1
Here is my build.gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion '20.0.0'
defaultConfig {
applicationId "com.joshcpd.android"
minSdkVersion 15
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.gms:play-services:5.2.08'
compile 'com.android.support:appcompat-v7:20.0.0'
compile project(':libraries:zbar')
}
I have tried removing the supportLappcompat dependency but then I get even more errors. Any help greatly appreciated.
I finally solved this issue by downloading the latest version of gradle.
I still get this error every so often and I just fix it by going to File ----> Invalidate caches/restart
I find Android Studio to be very buggy
Based on where it's trying to find the dx command:
/Applications/Android Studio.app/sdk/build-tools/android-4.4W/dx
it looks like you've crossed a build tools version with something else. The build file you posted in your question looks okay, but look in the other build files in your project (there's at least going to be something in libraries/zbar) and make sure their buildToolsVersion statements are okay. I suspect somewhere you have:
buildToolsVersion 'android-4.4W'
where you should have:
buildToolsVersion '20.0.0'
Now i know the reason of the problem. It was causes by wrong code in \sdk\android-sdk\tools\lib\find_java.bat
Wrong code:
find /i "x86" > NUL && set arch_ext=32 || set arch_ext=64
Correct code:
find /i "x86" > NUL && set arch_ext=32||set arch_ext=64
The wrong code leads to the path of java_exe be
E:\Android\sdk\ANDROI~1\tools\lib\\find_java32 .exe
So, when dx.bat runs
call "%java_exe%" %javaOpts% -Djava.ext.dirs="%frameworkdir%" -jar "%jarpath%" %params%
it will report the wrong status:
Error Code:
1
My platform: win8-32 bit android studio 1.0 - 4GB RAM
I had a similar issue, so I uninstalled the java jdk and reinstalled the latest version from oracle and everything went OK. The link for installing the latest version of jdk is here
Note: you need to update the jdk directory in android studio after doing the above

RenderScript BCC Compiler failed while running BasicRenderScriptSample

I have seen the question already asked in Can't find ScriptC_saturation in BasicRenderScript Sample
but as I am new in RenderScript, I can make it out they have already done much, so I cannot find the question as low level as I am asking:
I am using Eclipse Juno and have imported the BasicRenderScriptSample.
I am using the android.support.v8.renderscript (
(eclipse) project properties:
renderscript.target=18
renderscript.support.mode=true
sdk.buildtools=19.0.3
When I was not sure why the ScriptC_saturation is not auto generated, I was stuck till I followed the answer below, and copied the .rc file in the necessary folder, and everything compiled well.
Update:
Setup the necessary gradle properties as below (using jcenter rather than mavencentral):
apply plugin: 'com.android.application'
android {
compileSdkVersion 'android-L'
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.example.android.basicrenderscript"
minSdkVersion 'L'
targetSdkVersion 'L'
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile "com.android.support:appcompat-v7:18.0.+"
}
On Compilation I get this error in emulator and device all alike (from eclipse as well):
RenderScript﹕ bcc compiler terminated unexpectedly
RenderScript﹕ bcc: FAILS to prepare executable for 'saturation'
What could be the reason?
update 2: My Eclipse version of this project, somehow ran after series of cleaning, on the device (less than L) properly, but Gradle version project runs with THE error everywhere.
Don't put the .rs file in your res/ folders. It is a source file, not a resource. It dynamically creates .bc files which do end up automatically in your res/raw folder.

Android Studio can't find imported library

I've imported a library in Android studio (0.5.3)
My settings.graddle looks like this:
include ':app', ':libs:Android-PullToRefresh-master'
And my build.graddle looks like this:
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion '19.0.1'
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:19.+'
compile 'com.android.support:support-v4:19.+'
compile 'com.google.android.gms:play-services:4.2.42'
compile fileTree(dir: 'libs', include: ['*.jar'])
project(':libs:Android-PullToRefresh-master');
}
The folder I've downloaded is placed in the libs folder directly under the app folder. Also the graddle syncs and building doesn't provide any error. Yet whenever I try to import import com.handmark.xxxxxx; I get the error cannot resolve symbol 'handmark'. I've chcecked to project structure and the app has the dependency in the list.
What is going wrong and how can I fix this?
I ran into the same issue here and asked the question on the "Android Developer Tools" Google+'s community. Alex Ruiz picked up the conversation and told me:
I'm able to reproduce this issue. Unfortunately, no updates yet. We
are currently fixing the "Project Structure" (the core
infrastructure,) and we will get to this, hopefully soon.
So they are aware of it but we still have to wait until they fix it.
In the root of your project, run :
./gradlew clean && ./gradlew build
Then recompile your project in studio and you should see your new lib.
I had the exact same problem as this, however the library file was an aar file, and it happened a long time after adding the library and developing with it for a while.
Building on the information Thomas provided; I found to fix this you should replace the file dependency with a maven dependency if possible. A good resource for finding and creating your Gradle dependency is Gradle, please.
That site returns the below dependency when searching for PullToRefresh
dependencies {
compile 'com.loopeer.android.thirdparty.pulltorefresh:Android-PullToRefresh:2.1.1'
}

Categories

Resources