:app:transformClassesWithMultidexlistForDebug task failed - android

com.android.build.api.transform.TransformException :
Error while generating the main dex list.
com.android.tools.r8.errors.CompilationError:
Program type already present: com.xyja.bcclalib.BuildConfig
I have try these ways:
build clean my module
clean project
delete .gradle && build && .idea && [module]build
then rebuild my project
but I can't solved it. Anyone who can help me solve this? Thx.
This is my build.gradle(app).
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.xyja.bcclalib"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories{
flatDir {
dirs 'libs'
}
}
dependencies {
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation project(':BcClaLibirary')
implementation 'com.android.support:multidex:1.0.3'
}
And this is part of my build.gradle(BcClaLibirary).
apply plugin: 'com.android.library'
android {
...
}
dependencies {
implementation files('libs/bcprov-jdk15on-157.jar')
implementation files('libs/ksoap2-android-assembly-3.6.0-jar-with-dependencies.jar')
implementation files('libs/sun.misc.BASE64Decoder.jar')
implementation (name: 'ESecurityLib-release', ext: 'aar')
}
configurations.all {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
apply from: './nexus_maven.gradle'

Try this:
//app
repositories{
flatDir {
dirs 'libs'
dirs.project(':BcClaLibirary').files('libs')
//or you can use this way
//dirs 'libs', '../BcClaLibirary/libs'
}
}

Related

Android Studio to 3.0 - Unable to merge dex[DexArchiveMergerException]

I have project and I added another project as module and I have big problem with this error message:
Error:Execution failed for task
':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge
dex
I tried many solutions in stackoverflow and google but i don't found an answer.
For example:
I try added to defaultConfig multiDexEnabled true.
I try to clean and rebuild.
I try to Invalidate catch/Restart and then rebuild.
My project gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
My app gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "adms.foxitpdf"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation files('libs/FoxitRDK.jar')
compile project(path: ':uiextensions_src')
}
And my module gradle:
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
}
}
apply plugin: 'com.android.library'
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions{
abortOnError false
}
}
dependencies {
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:design:26.1.0'
implementation files('src/libs/FoxitRDK.jar')
}
task clearAar(type: Delete){
delete '../FoxitRDKUIExtensions.aar'
}
task makeAar(type: Exec){
dependsOn(clearAar,build)
def fromFile = 'build/outputs/aar/'
def intoFile = '../'
if(org.gradle.internal.os.OperatingSystem.current().windows) {
commandLine "cmd",
'-/C', 'copy', file("$fromFile/uiextensions_src-release.aar").absolutePath, file("$intoFile/FoxitRDKUIExtensions.aar")
}else {
commandLine "cp",
file("$fromFile/uiextensions_src-release.aar").absolutePath, file("$intoFile/FoxitRDKUIExtensions.aar")
}
}
makeAar {}.dependsOn(clearAar,build)
task makeJavaDoc(type: Javadoc) {
List<String> mSourcePath = new ArrayList<String>();
mSourcePath.add("../../fsdk/app/src/main/java/com/foxit/sdk/");
mSourcePath.add("src/main/java/com/foxit/uiextensions/UIExtensionsManager.java");
mSourcePath.add("src/main/java/com/foxit/uiextensions/Module.java");
mSourcePath.add("src/main/java/com/foxit/uiextensions/pdfreader/impl/PDFReader.java");
mSourcePath.add("src/main/java/com/foxit/uiextensions/controls/menu/IMenuView.java");
mSourcePath.add("src/main/java/com/foxit/uiextensions/controls/menu/MoreMenuConfig.java");
mSourcePath.add("src/main/java/com/foxit/uiextensions/controls/menu/MoreMenuModule.java");
mSourcePath.add("src/main/java/com/foxit/uiextensions/controls/toolbar/IBaseItem.java");
mSourcePath.add("src/main/java/com/foxit/uiextensions/controls/toolbar/IBarsHandler.java");
mSourcePath.add("src/main/java/com/foxit/uiextensions/controls/propertybar/IMultiLineBar.java");
source = mSourcePath;
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
Properties properties = new Properties()
InputStream inputStream = project.rootProject.file('local.properties').newDataInputStream() ;
properties.load( inputStream )
//读取文件
def sdkDir = properties.getProperty('sdk.dir')
ext.androidJar = sdkDir + "/extras/android/support/annotations/android-support-annotations.jar"
classpath += project.files(ext.androidJar)
destinationDir = file("../../docs/api_reference_android")
failOnError false
}
makeJavaDoc {
options {
encoding "UTF-8"
charSet 'UTF-8'
author true
version true
memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PUBLIC
locale = "en"
title = "Document of RDK for Android"
// fsdk overview
Map<String,List<String>> map = new HashMap<>();
List<String> fsdkOverViews= new ArrayList<>();
fsdkOverViews.add("com.foxit.sdk");
fsdkOverViews.add("com.foxit.sdk.*");
map.put("Fsdk Packages",fsdkOverViews);
// UIExtensions overview
List<String> uiExtendOverViews = new ArrayList<>();
uiExtendOverViews.add("com.foxit.uiextensions");
uiExtendOverViews.add("com.foxit.uiextensions.*");
map.put("UIExtenstions Packages",uiExtendOverViews);
groups = map;
}
}
I use with Android Studio to 3.0
Someone have idea why?
I guess you need to include this below one to your gradle as well as add dependencies and include in manifest also. If you have enabled only in gradle and does not include in manifest and dependencies then give it a shot.
multiDexEnabled true
add to your dependencies
dependencies {
compile 'com.android.support:multidex:1.0.1'
}
gradle file
android {
compileSdkVersion 25
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "adms.foxitpdf"
minSdkVersion 15
targetSdkVersion 24
versionCode 9
versionName "1.0"
multiDexEnabled true //Add this
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
Depending on how you override Application add this to your manifest.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapp">
<application
android:name="android.support.multidex.MultiDexApplication" >
...
</application>
</manifest>
or we can just do like this and again include in manifest with name tag.
public class MyApplication extends SomeOtherApplication {
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
Read full story here

Error:(22, 0) Could not find method android() for arguments

here's my gradle file
I am getting this error
Error:(22, 0) Could not find method android() for arguments
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
android {
defaultConfig {
minSdkVersion 26
targetSdkVersion 26
}
productFlavors {
}
}
dependencies {
}
You need to apply a plugin to your build.gradle file. Only then you will be able to use the android block. Add any of these two lines at the top of your build.gradle file:
Application : apply plugin: 'com.android.application'
Library : apply plugin: 'com.android.library'
Your App Gradle should look like something like this
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "com.armenhovhannisyan.backpaper.backpaper"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.0.0-beta1'
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:design:26.0.0-beta1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
}

how does the gradle dependencies work, i can not find any function relate with it in the gradle source code

how does the gradle dependencies work, i can not find any function relate with it in the gradle source code.
please help me , I googled this but found nothing...
dependencies {
}
gradle dependencies work from build.gradle(Module:app)
buildscript {
repositories {
....
}
dependencies {
...........
}
}
apply plugin: 'com.android.application'
apply plugin: '..'
repositories {
.....
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
defaultConfig {
applicationId "your pkg name"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
}
//Here you can add your dependencies
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.google.android.gms:play-services-ads:8.4.0'
compile 'com.google.android.gms:play-services-identity:8.4.0'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
........
}

Android Annotations could not find AndroidManifest.xml

I've checked a few different questions, but none of them provided a solution which worked for me. I'm developing a project with Android Annotations, and when I attempt to build my project it fails with the following error (Project_Location is simply my local project folder):
error: Could not find the AndroidManifest.xml file in specified path : [/Project_Location/mobile/build/intermediates/manifests/full/debug/AndroidManifest.xml]
Here is my mobile build.gradle file:
apply plugin: 'com.android.application'
ext.androidAnnotationsVersion = '3.3.2';
ext.eventBusVersion = '2.4.0';
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
}
}
apply plugin: 'android-apt'
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
wearApp project(':wear')
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.google.android.gms:play-services:8.3.0'
apt "org.androidannotations:androidannotations:${androidAnnotationsVersion}"
compile "org.androidannotations:androidannotations:${androidAnnotationsVersion}"
apt "de.greenrobot:eventbus:${eventBusVersion}"
compile "de.greenrobot:eventbus:${eventBusVersion}"
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.dev.app_name"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "0.3"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
configurations {
apt
}
apt {
arguments {
androidManifestFile variant.outputs.processResources.manifestFile
resourcePackageName 'com.dev'
}
}
android.applicationVariants.each { variant ->
aptOutput = file("${project.buildDir}/source/apt_generated/${variant.dirName}")
println "****************************"
println "variant: ${variant.name}"
println "manifest: ${variant.processResources.manifestFile}"
println "aptOutput: ${aptOutput}"
println "****************************"
variant.javaCompile.doFirst {
println "*** compile doFirst ${variant.name}"
aptOutput.mkdirs()
variant.javaCompile.options.compilerArgs += [
'-processorpath', configurations.apt.getAsPath(),
'-AandroidManifestFile=' + variant.processResources.manifestFile,
'-s', aptOutput
]
}
}
If the build.gradle file looks like a mess, I've tried to implement multiple solutions already without success. So if there's redundant statements that can be removed feel free to provide those suggestions as well. Right now, I'm just stumped as to why it can't locate my manifest file which is clearly present.
I fixed your build script which should be working regarding AndroidAnnotations:
apply plugin: 'com.android.application'
ext.androidAnnotationsVersion = '3.3.2';
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
}
apply plugin: 'com.neenbedankt.android-apt'
dependencies {
apt "org.androidannotations:androidannotations:${androidAnnotationsVersion}"
compile "org.androidannotations:androidannotations-api:${androidAnnotationsVersion}"
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.dev.app_name"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "0.3"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
apt {
arguments {
androidManifestFile variant.outputs[0]?.processResources?.manifestFile
resourcePackageName "com.dev.app_name" // the same as package in the manifest
}
}
Update: to use with annotationProcessor instead of apt:
android {
defaultConfig {
javaCompileOptions {
annotationProcessorOptions {
arguments = ["resourcePackageName": "com.dev.app_name"]
}
}
}
}
And make sure you are using the latest version of AndroidAnnotations.

Crashylitcs integration with android lib

I'm debugging stuff on a lib and was trying to integrate crashlytics on it. At first, I've followed this, and after some problems, managed to build the library without errors.
The thing is: when I try to use Fabric.with(this, new Crashlytics(), new CrashlyticsNdk()) in the app which uses that lib, it gives me an "symbol cannot be resolved".
I've tried moving this line into the lib, but all I've got was a NoClassDefFoundError.
Any suggestions?
Below, my lib gradle
apply plugin: 'com.android.library'
android {
compileSdkVersion 20
buildToolsVersion '20'
defaultConfig {
minSdkVersion 9
targetSdkVersion 9
versionCode 1
versionName "1.0"
}
buildTypes {
release {
}
}
productFlavors {
}
}
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/mylib.jar')
compile('com.crashlytics.sdk.android:crashlytics:2.5.2#aar') {
transitive = true;
}
compile('com.crashlytics.sdk.android:crashlytics-ndk:1.1.0#aar') {
transitive = true
}
}
and my app gradle:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
android {
compileSdkVersion 20
buildToolsVersion '20'
defaultConfig {
applicationId 'com.test.app'
minSdkVersion 15
targetSdkVersion 20
versionCode 1
versionName '1.0'
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
packagingOptions {
exclude 'LICENSE.txt'
}
sourceSets {
androidTest.setRoot('src/test')
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt')
}
}
productFlavors {
}
splits {
abi {
enable true
reset()
include 'armeabi'
}
}
}
repositories {
flatDir { dirs 'libs' }
}
dependencies {
compile(name: 'my-framework', ext: 'aar')
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.0'
androidTestCompile 'com.android.support.test:testing-support-lib:0.1'
}

Categories

Resources