I'm using Android Studio and AndEngine library and TexturePacker Extension using this link to setup:
Setting Up AndEngine with Android Studio
I'm getting that issue:
Error:Class org.andengine.BuildConfig has already been added to output. Please remove duplicate copies.
1 error; aborting
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\Users\Diego\android-sdks\build-tools\21.1.2\dx.bat --dex --no-optimize --output C:\Users\Diego\NEXT\Next\app\build\intermediates\dex\debug --input-list=C:\Users\Diego\NEXT\Next\app\build\intermediates\tmp\dex\debug\inputList.txt
Error Code:
1
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Lorg/andengine/BuildConfig;
at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:122)
at com.android.dx.dex.file.DexFile.add(DexFile.java:161)
at com.android.dx.command.dexer.Main.processClass(Main.java:732)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:673)
at com.android.dx.command.dexer.Main.access$300(Main.java:83)
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:510)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:280)
at com.android.dx.command.dexer.M...(Main.java:246)
at com.android.dx.command.dexer.Main.main(Main.java:215)
at com.android.dx.command.Main.main(Main.java:106)
1 error; aborting
I've tried everything. Cleaning project, deleting BuildConfig classes (they are created automatically in texturepacker library), excluding modules, reimporting third_party libraries... but nothing seems to fix it.
Here my build.gradle files:
App:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.zmaxstudios.next"
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
preDexLibraries = false
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:support-v13:21.0.3'
compile project(':third_party:andengine')
compile project(':third_party:texturepacker')
}
AndEngine > build.gradle
apply plugin: 'android-library'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 14
targetSdkVersion 21
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-project.txt')
}
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
instrumentTest.setRoot('tests')
}
}
Texturepacker > build.gradle
apply plugin: 'android-library'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 14
targetSdkVersion 21
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-project.txt')
}
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
instrumentTest.setRoot('tests')
}
}
dependencies {
compile project(':third_party:andengine')
}
How can remove duplicated BuildConfig files? Or what should I do to fix that?
Thanks
Your problem looks like it lies in your dependencies, something like this, in my case.
compile 'com.google.android.gms:play-services:6.5.87'// and here's the issue
The Google Play Services libraries can be quite large and when combining in a lot of third party libraries or some newer Google libraries, that can be redundancies as your experiencing. I ran into a similar issues when implementing Google Cloud Storage. Typically I now just include what I really need from the android support libraries, i.e.
compile 'com.google.apis:google-api-services-storage:v1-rev18-1.19.0'
compile 'com.google.http-client:google-http-client-jackson2:1.20.0'
compile 'com.google.oauth-client:google-oauth-client-jetty:1.20.0'
compile 'com.google.api-client:google-api-client-java6:1.20.0'
compile 'com.google.android.gms:play-services-maps:7.3.0'
compile 'com.google.android.gms:play-services-location:7.3.0'
can you please remove this line from dependencies I'm seeing here you are using two support libraries. clean and build your project
compile 'com.android.support:support-v13:21.0.3'
I've finally solved the problem, that it wasn't with support libraries. I was getting the problem form third_party libraries, because manifest file of texturepacker library had the same package of andengine following the steps in link provided in the question, so BuildConfig.java classes was being duplicated. Now, the manifest files are:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.andengine" >
<application>
</application>
</manifest>
And texturepacker:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.andengine.extension.texturepacker.opengl.texture.util.texturepacker" >
<application>
</application>
</manifest>
Hope that can be helpfull.
Thanks all the answers.
Related
I'm developing an application for a device that has an SDK for itself.
When I try to import its SDK as a library in my application I will get an error like below:
E/MultiWindowProxy: getServiceInstance failed!
E/MultiWindowProxy: getServiceInstance failed!
E/AndroidRuntime: FATAL EXCEPTION: Thread-571
Process: cards.mena.app, PID: 9484
java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/cards.mena.app-2/base.apk"],nativeLibraryDirectories=[/data/app/cards.mena.app-2/lib/arm, /vendor/lib, /system/lib]]] couldn't find "libserial_port.so"
at java.lang.Runtime.loadLibrary(Runtime.java:367)
at java.lang.System.loadLibrary(System.java:1076)
at android_serialport_api.SerialPort.<clinit>(Unknown Source)
at com.rt.printerlibrary.driver.serialport.ComDriver.a(Unknown Source)
at com.rt.printerlibrary.driver.serialport.ComDriver.run(Unknown Source)
I put the .Jar file and .so into libs folder in my application like below:
And this is my Gradle file:
android {
compileSdkVersion 28
defaultConfig {
applicationId "cards.mena.app"
minSdkVersion 21
targetSdkVersion 28
versionCode 10002
versionName "1.0.2"
setProperty("archivesBaseName", "MenaCards-v$versionName")
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled = true
}
sourceSets {
main {
// manifest.srcFile 'AndroidManifest.xml'
jniLibs.srcDirs = ['libs']
// java.srcDirs = ['src']
// resources.srcDirs = ['src']
assets.srcDirs = ['assets']
}
}
}
androidExtensions {
experimental = true
}
kapt {
generateStubs = true
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.anko:anko-commons:0.10.8"
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation "com.android.support:design:$supportLibraryVersion"
/*----------------/ Printer Libs \---------------------------*/
implementation files('libs/printer_library_ap02.jar')
Update:
I downgrade my Gradle form 3.5.0 to 2.3.2 and my application is working now!
Then the problem is Gradle! What I have to do with that?
I found the problem and its answer.
The problem was about Gradle version and I had to add this line:
defaultConfig {
ndk {
abiFilters 'armeabi'
}
}
I put my .so files in src > main > jniLibs and there in the architecture dependent subfolders arm64-v8a, armeabi-v7a, ... . Don't need additional configuration then. May be this helps you.
I found the solution, you don't have to as a gradle dependency add it in the gradle app file.
android{
sourceSets {
main {
jniLibs.srcDirs = ['libs']
assets.srcDirs = ['assets']
}
}
}
I had the same problem, as #Ehsan suggested it worked.
I would like to point out something though, you don't need to downgrade your gradle.
If you'd like to put your .so files in the libs folder then you'd need to add
sourceSets {
main {
jniLibs.srcDirs = ['libs']
assets.srcDirs = ['assets']
}
}
Its not necessary if you already added them in the jniLibs folder.
Then adding
defaultConfig {
ndk {
abiFilters 'armeabi'
}
}
made it all work out well.
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.
I have an issue to import mupdf library into my android application. The problem is that the program was running well last week, and I probably changed something in the code that don't load mupdf anymore. If I try to load a pdf file, I have a message with "-my application- has stopped". Here is the logcat error message :
2530-2530/com.efc.efcredader E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.ExceptionInInitializerError
at com.artifex.mupdfdemo.MuPDFActivity.openFile(MuPDFActivity.java:944)
at com.artifex.mupdfdemo.MuPDFActivity.onCreate(MuPDFActivity.java:710)
[...]
Caused by: java.lang.UnsatisfiedLinkError: Couldn't load mupdf: findLibrary returned null
at java.lang.Runtime.loadLibrary(Runtime.java:365)
at java.lang.System.loadLibrary(System.java:535)
at com.artifex.mupdfdemo.MuPDFCore.<clinit>(MuPDFCore.java:16)
[...]
I call the libmupdf.so like that :
static {
System.loadLibrary("mupdf");
}
I've followed a lot a tutorials about how to build mupdf as a library and import it but no one works well (at least for me). So I suppose (and I hope), I'm doing something wrong during the manipulation.
After I imported the "Android" module from mupdf, the folder is like that :
>android
>manifests
Android.Manifest.xml
>java
>com.artifex.mupdfdemo
All java files
>res
>animator
Xml files
>drawable
Xml files
>layout
Xml files
>values
Xml files
>c
Android.mk
Application.mk
Core.mk
libmupdf.so
mupdf.c
ThirdParty.mk
Even if I try to compile it alone, I have some errors too :
make.exe:***No rule to make target ...
and
Execution failed for task ':android:compileDebugNdk'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\android-ndk-r10d\ndk-build.cmd'' finished with non-zero exit value 2
Here is the project's build.gradle
apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':appcompat_v7')
compile project(':android-support-v4-preferencefragment-master')
compile project(':android-support-v7-gridlayout')
}
android {
compileSdkVersion 19
buildToolsVersion "19.1"
compileOptions.encoding = 'ISO-8859-1'
packagingOptions {
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LICENSE.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']
}
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
android's build.gradle :
apply plugin: 'com.android.library'
android {
compileSdkVersion 16
buildToolsVersion "19.1.0"
defaultConfig {
//applicationId "com.artifex.mupdfdemo"
minSdkVersion 8
targetSdkVersion 16
ndk {
moduleName "mupdf"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
local.properties
sdk.dir=C\:\\Android\\SDK
ndk.dir=C\:\\android-ndk-r10d
I'm using Android Studio and the SDK is up to date.
I really don't know how to solve that right now, I would be glad If you have any advice that can help me. If you need any other details or files to add, just ask.
Thank you.
My solution is:
I'm having the .so files in lib/armeabi and lib/armeabi-v7a, and in the build.gradle I added jniLibs.srcDirs = ['libs'] to the existing sourcesets. Hope that is helping you!
I am getting errors as below when i tried running my module,
Error:Gradle: Attribute "titleTextStyle" has already been defined
Error:Gradle: Attribute "subtitleTextStyle" has already been defined
[...]
In the project there are two modules ModuleA & ModuleB
ModuleA is library. ModuleB depend on ModuleA
Build.gradle file of ModuleA
apply plugin: 'android-library'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
res.srcDirs = ['res']
}
}
}
dependencies {
compile files('libs/quickblox-android-sdk-core-2.0.jar')
compile 'com.android.support:appcompat-v7:18.0.+'
}
Build.gradle file of ModuleB
apply plugin: 'com.android.application'
android {
compileSdkVersion 18
buildToolsVersion "21.0.0"
defaultConfig {
applicationId "com.td.tdabslidingmenu"
minSdkVersion 11
targetSdkVersion 18
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0#aar'
compile 'com.android.support:support-v4:18.+'
compile project(':sample-users')
}
i tried commenting compile 'com.actionbarsherlock:actionbarsherlock:4.4.0#aar'
and compile 'com.android.support:appcompat-v7:18.0.+'
separately as mentioned in other threads for each Run but no use...
search your project for (cmd+shift+f) titleTextStyle where is this being declared is it you or is it in something external you are using
the issue is in xml attributes being defined twice. Can have multiple causes. The obvious one being check your styles.xml and attrs.xml
Next remove the double compile of 'com.android.support:support-v4:18.+'
I would also targetSdkVersion 21 for all modules
you need to comment compile 'com.android.support:appcompat-v7:18.0.+', as said Tanis.7x - "ActionBarSherlock has been deprecated for quite some time and you should not be using it any more"
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