I got the source of a project (An android application) from github and I am trying to launch it, the project is called "RtkGps+" it's an Anroid application to that use a C++ libary called Rtklib to play with GPS and Raw measurements.
My Android environment configuration is bellow,
Gradle version : 3.1.3
NDK revision : 19.0.5232133
I'm unable to compile the project, I got the errors bellow :
As shown in the the capture there are many errors, that I want to enumate them,
So the first one is this error where the NDK_PROJECT_PATH=null
SIMPLE: Error while executing process C:\Users\Yazid\AppData\Local\Android\Sdk\ndk-bundle\ndk-build.cmd with arguments {NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=C:\Users\Yazid\Documents\Dev\Android\RtkGps-master\RtkGps-master\jni\Android.mk NDK_APPLICATION_MK=C:\Users\Yazid\Documents\Dev\Android\RtkGps-master\RtkGps-master\jni\Application.mk APP_ABI=armeabi-v7a NDK_ALL_ABIS=armeabi-v7a NDK_DEBUG=0 APP_PLATFORM=android-21 NDK_OUT=C:/Users/Yazid/Documents/Dev/Android/RtkGps-master/RtkGps-master/build/intermediates/ndkBuild/release/obj NDK_LIBS_OUT=C:\Users\Yazid\Documents\Dev\Android\RtkGps-master\RtkGps-master\build\intermediates\ndkBuild\release\lib APP_SHORT_COMMANDS=false LOCAL_SHORT_COMMANDS=false -B -n}
The second one is saying that the Android.mk file is not supported
SIMPLE: Android NDK: WARNING: Unsupported source file extensions in C:\Users\Yazid\Documents\Dev\Android\RtkGps-master\RtkGps-master\jni\Android.mk for module rtklib
I tried adding gradle code from this answer : https://stackoverflow.com/a/50707270/6306138
The Gradle file of the project.
buildscript {
repositories {
mavenCentral()
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
}
}
apply plugin: 'com.android.application'
repositories {
mavenCentral()
jcenter()
google()
}
dependencies {
implementation group: 'cz.msebera.android' , name: 'httpclient' , version: '4.4.+'
implementation 'com.android.support:support-v13:27.1.1'
implementation 'com.google.gms:google-services:3.2.1'
implementation 'com.google.android.gms:play-services-gcm:11.0.4'
implementation 'com.google.code.findbugs:jsr305:3.0.2'
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.jakewharton:butterknife:8.8.1'
implementation 'com.karumi:dexter:5.0.0'
implementation 'ch.acra:acra:4.5.0'
implementation 'commons-net:commons-net:3.6'
implementation 'org.slf4j:slf4j-api:1.7.25'
implementation 'com.infstory:proguard-annotations:1.0.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
}
android {
sourceSets.main.res.filter.exclude '**/proj4/jniwrap/org/**'
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
compileSdkVersion 26
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "gpsplus.rtkgps"
minSdkVersion 21
targetSdkVersion 26
multiDexEnabled true
ndk {
abiFilters = []
abiFilters.add('armeabi-v7a')
abiFilters.add('x86')
abiFilters.add('x86_64')
abiFilters.add('arm64-v8a')
}
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
jniLibs.srcDir 'libs'
}
// instrumentTest.setRoot('tests')
}
externalNativeBuild {
ndkBuild {
path 'jni/Android.mk'
}
}
packagingOptions{
doNotStrip '*/mips/*.so'
doNotStrip '*/mips64/*.so'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
buildTypes {
debug {
debuggable true
jniDebuggable false
renderscriptDebuggable false
}
}
productFlavors {
}
}
Neither of the "errors" mentioned are errors. NDK_PROJECT_PATH=null is normal behavior for Studio, and the second is just a warning.
Without seeing your Android.mk or the full error message (the line immediately after the one you included tells you what went wrong) I can't tell you how to fix the warning, but like the warning says, one of your source files has an unrecognized extension so ndk-build didn't know how to build it.
Related
I have a dummy project, which I succeed to compile through buildship plugin in eclipse IDE.
This is my local.properties file:
sdk.dir=C:/Asta/altro/adt-bundle/sdk
This is settings.gradle file
rootProject.name = 'testgradle'
This is my build.gradle file
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
}
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.example.testgradle"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
}
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
lintOptions {
abortOnError false
}
}
sourceCompatibility = 1.6
targetCompatibility = 1.6
repositories {
jcenter()
flatDir {
dirs 'libs'
}
}
dependencies {
compile 'org.slf4j:slf4j-api:1.7.21'
compile 'com.android.support:appcompat-v7:23.4.0'
testCompile 'junit:junit:4.12'
}
task wrapper(type: Wrapper) {
gradleVersion = '2.10'
}
Despite I got the apk fully compiled, eclipse is not integrated: still seeing missing libraries and giving more than a 100 errors! All the libs are perfectly managed by gradle in \build\intermediates\ and assembled into apk, but the eclipse IDE is not "live". I would like to use gradle to download and explode the libraries and then to inform eclipse and let it to make the apk with its own builder.
Buildship can be used only to run Android tasks (assembleDebug).
During the build process it will load dependencies and tell if there're some errors.
To load dependencies into Java classpath, to see errors in Eclipse and resolve imports you can either manually add .jar files to your Java Build Path or use this Gradle plugin: https://github.com/greensopinion/gradle-android-eclipse.
It generates classpath for Eclipse project and you just import it into the IDE.
To run Gradle tasks you can create a Run configuration (named "Gradle Project") and put there your task and Working directory.
Having an issue where the apk being generated by our Gradle build contains a bunch of unnecessary files inside a test/resources directory
Our application build gradle contains several local module dependencies which are built as android libraries.
I know there is packagingOptions field in Gradle but you can't exclude directories as far as I can tell. Excluding each file isn't an option. Anyway, I would like to know the root cause for this.
Application gradle build:
apply from: "${rootDir}/android_application.gradle"
dependencies {
compile project(':local-lib1')
//... etc
compile project(':local-libN')
testCompile libraries['junit']
}
android {
defaultConfig {
versionCode 1
versionName "1.0"
multiDexEnabled true
}
}
And android_application.gradle:
apply plugin: 'com.android.application'
android {
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
resources.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
compileSdkVersion android_sdk_version
buildToolsVersion android_build_tools_version
defaultConfig {
minSdkVersion android_min_sdk_version
targetSdkVersion android_target_sdk_version
}
buildTypes {
}
}
All modules are structured like so:
module
|
--AndroidManifest.xml
--build.gradle
--assets/
--res/
--src
|
-- main/
| |
| --java/
| --resources/
|
-- test/
|
--java/
--resources/
Why are test/resources being included in apk? How can I exclude them?
Edit (to show lib gradle):
Example lib gradle:
apply from: "${rootDir}/android_library.gradle"
dependencies {
compile 'com.android.support:multidex:1.0.0'
// ...etc external deps
// test deps
testCompile libraries['logback-classic']
testCompile libraries['junit']
testCompile libraries['mockito-core']
// etc...
}
android {
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
exclude 'META-INF/ASL2.0'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
}
}
android_library gradle:
apply plugin: 'android-library'
android {
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
resources.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
compileSdkVersion android_sdk_version
buildToolsVersion android_build_tools_version
defaultConfig {
minSdkVersion android_min_sdk_version
targetSdkVersion android_target_sdk_version
}
buildTypes {
release {
}
}
}
I am building with gradlew.bat -x test build
The test/resources included in the apk contains all the files in the corresponding test/resources for each lib. The size of directory (uncompressed) is 10mb so adds unreasonable amount to size of overall apk.
Try the resource shrinking. As per Google Documentation: "The Gradle build system for Android supports
resource shrinking": the automatic removal of resources that are
unused, at build time, in the packaged app. In addition to removing
resources in your project that are not actually needed at runtime,
this also removes resources from libraries you are depending on if they are not actually needed by your application
android {
...
buildTypes {
test {
minifyEnabled true
shrinkResources true
...
}
}
}
Think I've solved the issue.
I had in app build.gradle and each library build.gradle:
android {
sourceSets {
main {
resources.srcDirs = ['src']
}
}
}
Changed to
android {
sourceSets {
main {
resources.srcDirs = ['src/main']
}
}
}
I guess gradle was taking every resources dir under src/ and merging them into one - http://tools.android.com/tech-docs/new-build-system/resource-merging
I recently upgraded from Android Studio 0.9.2 to 1.0 (including version 1.0.0 of the Gradle plugin) and I'm having an issue with building my project.
Whenever I build I get the following exception at the dexDebug or dexRelease step:
UNEXPECTED TOP-LEVEL ERROR:
java.lang.OutOfMemoryError: GC overhead limit exceeded
at java.util.HashMap.createEntry(HashMap.java:897)
at java.util.HashMap.addEntry(HashMap.java:884)
at java.util.HashMap.put(HashMap.java:505)
at com.android.dx.rop.type.Type.putIntern(Type.java:857)
at com.android.dx.rop.type.Type.intern(Type.java:365)
at com.android.dx.rop.type.Type.internClassName(Type.java:415)
at com.android.dx.cf.cst.ConstantPoolParser.parse0(ConstantPoolParser.java:289)
at com.android.dx.cf.cst.ConstantPoolParser.parse0(ConstantPoolParser.java:299)
at com.android.dx.cf.cst.ConstantPoolParser.parse(ConstantPoolParser.java:150)
at com.android.dx.cf.cst.ConstantPoolParser.parseIfNecessary(ConstantPoolParser.java:124)
at com.android.dx.cf.cst.ConstantPoolParser.getPool(ConstantPoolParser.java:115)
at com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:482)
at com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406)
at com.android.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary(DirectClassFile.java:388)
at com.android.dx.cf.direct.DirectClassFile.getMagic(DirectClassFile.java:251)
at com.android.dx.command.dexer.Main.processClass(Main.java:704)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:673)
at com.android.dx.command.dexer.Main.access$300(Main.java:82)
at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:602)
at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:632)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:505)
at com.android.dx.command.dexer.Main.runMultiDex(Main.java:332)
at com.android.dx.command.dexer.Main.run(Main.java:243)
at com.android.dx.command.dexer.Main.main(Main.java:214)
at com.android.dx.command.Main.main(Main.java:106)
I tried increasing the heap size of Android Studio to -Xmx4096m but to no avail.
In Android Studio 0.9.2 with version 0.14 of the gradle plugin building worked fine.
This is the build.gradle file of my project:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
}
}
And this is the build.gradle file of my module:
apply plugin: 'android'
repositories {
mavenCentral()
}
dependencies {
compile 'com.android.support:appcompat-v7:21.+'
compile 'com.android.support:cardview-v7:21.0.+'
compile 'com.android.support:recyclerview-v7:21.0.+'
compile 'com.android.support:multidex:1.+'
compile 'com.google.android.gms:play-services:6.5.+'
compile 'org.jsoup:jsoup:1.8.+'
compile 'commons-io:commons-io:2.4'
compile 'org.apache.commons:commons-lang3:3.3.2'
compile 'com.rometools:rome:1.5.0'
compile 'com.google.apis:google-api-services-blogger:v3-rev44-1.19.0'
compile 'com.google.http-client:google-http-client-gson:1.19.0'
compile 'org.apache.commons:commons-collections4:4.0'
compile 'com.parse.bolts:bolts-android:1.1.2'
compile files('libs/android-query.0.26.8.jar')
compile files('libs/Parse-1.7.1.jar')
}
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
defaultConfig {
// Enabling multidex support.
multiDexEnabled true
minSdkVersion 10
targetSdkVersion 21
versionCode 1040009
versionName "1.4"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-dcrapp.txt'
shrinkResources true
}
debug {
minifyEnabled false
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-dcrapp.txt'
}
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
//Bugfix for Gradle build bug
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
task copyMappingFiles(type: Copy)
copyMappingFiles {
from 'build\\outputs\\mapping\\release'
into 'mappings\\'+android.defaultConfig.versionCode
include('mapping.txt')
}
assembleRelease.finalizedBy copyProguardFiles
What could be the cause of this issue and how can it be solved?
Looks like Android Studio ran out of memory, try increasing the memory size in AndroidStudio.app/Contents/bin/studio.vmoptions
-Xms256m
-Xmx1024m
-XX:MaxPermSize=350m
-XX:ReservedCodeCacheSize=96m
-XX:+UseCompressedOops
as per suggested from answers in Android Studio - How to increase Allocated Heap Size
Additionally you may want to add
dexOptions {
javaMaxHeapSize "4g"
}
to your module build.gradle as per Android Studio Google JAR file causing GC overhead limit exceeded error
Looks like dexing runs out of memory. Try:
android {
dexOptions {
javaMaxHeapSize "2048M"
}
}
For additional options, see dex options in the Gradle Plugin User Guide.
I am trying to make a Hello World with AndroidAnnotations and Gradle in IntelliJ IDEA.
(I only have some experience with IntelliJ, all the other stuff is completely new to me.)
I have created a new Gradle: Android Module in IntelliJ IDEA and then edited build.gradle per "Configure your gradle" in the AndroidAnnotations' official guide.
Unfortunatelly, I get this error saying I have no idea what (on line 18: apply plugin: 'android-apt')
Gradle: A problem occurred evaluating project ':Hello'.
> Could not find property 'androidTestCompile' on configuration container.
Here is my build.gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.7.+'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.+'
}
}
repositories {
mavenCentral()
mavenLocal() // cache (USER_HOME/.m2 folder)
}
apply plugin: 'android'
apply plugin: 'android-apt' // This is the line of the error
def AAVersion = '3.0.1' // IS THIS OK?
dependencies {
compile 'com.android.support:appcompat-v7:+'
compile 'com.android.support:support-v4:18.0.0'
apt "org.androidannotations:androidannotations:$AAVersion"
compile "org.androidannotations:androidannotations-api:$AAVersion"
}
apt {
arguments {
androidManifestFile variant.processResources.manifestFile
resourcePackageName 'com.hello.app'
// If you're using Android NBS flavors you should use the following line instead of hard-coded packageName
// resourcePackageName android.defaultConfig.packageName
// You can set optional annotation processing options here, like these commented options:
// logLevel 'INFO'
// logFile '/var/log/aa.log'
}
}
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
minSdkVersion 7
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
// This is only needed if you project structure doesn't fit the one found here
// http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Project-Structure
sourceSets {
main {
manifest.srcFile 'src/main/AndroidManifest.xml'
// java.srcDirs = ['src/main/java', 'build/generated/source/apt/${variant.dirName}']
// resources.srcDirs = ['src/main/resources']
res.srcDirs = ['src/main/res']
// assets.srcDirs = ['src/main/assets']
}
}
}
Version Compatibility.
androidTestCompile was introduced in version 0.9.0 of the Android Gradle plugin (and I was using 0.7.+ here), so 0.9.0 is the minimum one should use with android-apt's newer versions (3.0.1 here).
Also, you might have some more problems with incompatible versions of all these tools.
Here is a table of version compatibility among Android Studio, Android Gradle plugin and Gradle
I tried to use the APK Expansion libs zip_file and downloader_library (which requires play_licensing). zip_file worked fine since it has no dependencies, but play_licensing throws an error when I try a Gradle sync.
Android Studio spits out this error log:
Information:Gradle tasks [:app:generateGoogleDebugSources, :app:libs:downloader_library:generateDebugSources, :app:libs:play_licensing:generateDebugSources, :app:libs:zip_file:generateDebugSources]
Information:/Users/faiz/Projects/Android/TogetherTime/app/libs/play_licensing/aidl/ILicenseResultListener.aidl:21 interface ILicenseResultListener should be declared in a file called com/android/vending/licensing/ILicenseResultListener.aidl.
Information:2 errors
Information:0 warnings
Information:See complete output in console
/Users/faiz/Projects/Android/TogetherTime/app/libs/play_licensing/aidl/ILicensingService.aidl
Error:(19) couldn't find import for class com.android.vending.licensing.ILicenseResultListener
Error:(19) Execution failed for task ':app:libs:play_licensing:compileReleaseAidl'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
/Users/faiz/Projects/Android/android-sdk-macosx/build-tools/19.0.3/aidl -p/Users/faiz/Projects/Android/android-sdk-macosx/platforms/android-19/framework.aidl -o/Users/faiz/Projects/Android/TogetherTime/app/libs/play_licensing/build/source/aidl/release -I/Users/faiz/Projects/Android/TogetherTime/app/libs/play_licensing/aidl -I/Users/faiz/Projects/Android/TogetherTime/app/libs/play_licensing/src/release/aidl -d/var/folders/y6/g0d5m3f94rxdvq5myp53d9k80000gn/T/aidl662748145109587430.d /Users/faiz/Projects/Android/TogetherTime/app/libs/play_licensing/aidl/ILicensingService.aidl
Error Code:
1
Output:
/Users/faiz/Projects/Android/TogetherTime/app/libs/play_licensing/aidl/ILicensingService.aidl:19: couldn't find import for class com.android.vending.licensing.ILicenseResultListener
I haven't modified any of the libraries, but since they weren't built for Gradle, I copied over a build.gradle from another project and modified them accordingly.
downloader_library/build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
}
apply plugin: 'android-library'
dependencies {
compile 'com.android.support:support-v4:+'
compile project(':app:libs:play_licensing')
}
android {
compileSdkVersion 19
buildToolsVersion "19.0.3"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
res.srcDirs = ['res']
}
}
defaultConfig {
minSdkVersion 4
targetSdkVersion 19
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
play_licensing/build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
}
apply plugin: 'android-library'
dependencies {
compile 'com.android.support:support-v4:+'
}
android {
compileSdkVersion 19
buildToolsVersion "19.0.3"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
res.srcDirs = ['res']
aidl.srcDirs = ['aidl']
}
}
defaultConfig {
minSdkVersion 3
targetSdkVersion 19
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
I'm currently using Android Studio 0.5.1 and gradle 0.9.0 with build tools 19.0.3
I had the same problem and found solution for it. Just create a new package with the name com.android.vending.licensing under the aidl folder and move your aidl files there:
P.S. you also have to add empty <application /> tags to AndroidManifest.xml of play_licensing and downloader_library modules. And compile project(':PlayLicensing') to the dependencies tag of the build.gradle of the downloader_library