Can't import external project as module in Android Studio 3 - android

I have an app already published on the store, after upgrading to Android Studio 3 (now 3.1) and the forced update of gradle I am unable to import my external projects as modules.
I have tried removing all my modules and adding them one by one, deleting the cache, changing gradle version, and compileSdkVersion but it doesn't work.
When I try to sync gradle I receive some messages like this:
Unable to resolve dependency for ':app#produzioneDebug/compileClasspath': Failed to transform file 'ShareLib-release.aar' to match attributes {artifactType=android-exploded-aar} using transform ExtractAarTransform
This is in my settings.gradle to make external project available:
include ':app'
include ':ShareLib'
project(':ShareLib').projectDir = new File('..//ShareLib//')
This is my build.gradle
buildscript {
repositories {
jcenter()
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'io.fabric.tools:gradle:1.+'
}
}
repositories {
jcenter()
mavenCentral()
mavenLocal()
maven {
url 'https://repo.spring.io/libs-milestone'
}
maven { url 'https://maven.fabric.io/public' }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
def AAVersion = '4.4.0'
android {
compileSdkVersion 26
buildToolsVersion "27.0.3"
defaultConfig {
minSdkVersion 15
targetSdkVersion 26
versionCode 3
versionName "1.0.0.0"
applicationId "com.xxx.app"
// Enabling multidex support.
multiDexEnabled true
javaCompileOptions {
annotationProcessorOptions {
arguments = ["resourcePackageName": android.defaultConfig.applicationId]
}
}
}
signingConfigs {
releaseSigning {
///
}
}
buildTypes {
debug {
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
zipAlignEnabled true
}
release {
// proguard
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
shrinkResources false
zipAlignEnabled true
signingConfig signingConfigs.releaseSigning
}
}
flavorDimensions "tier"
productFlavors {
dev {
buildConfigField "String", "SERVICE_URL_BASE", "\"dev.xxx.com/xxx-rest\""
applicationId "development.xxx.app"
}
coll {
buildConfigField "String", "SERVICE_URL_BASE", "\"dev.xxx.com/xxx-rest\""
applicationId "test.xxx.app"
}
prod {
buildConfigField "String", "SERVICE_URL_BASE", "\"www.xxx.com/xxx-rest\""
applicationId "com.xxx.app"
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
dexOptions {
javaMaxHeapSize "4g"
}
lintOptions {
checkReleaseBuilds false
abortOnError false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation project(path: ':shareLib', configuration: 'default')
// implementation project(path: ':shareLib', configuration: 'default') {
// exclude module: 'jsr305'
// }
// compile fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.12'
implementation 'com.squareup:otto:1.3.8'
implementation 'org.springframework.android:spring-android-rest-template:2.0.0.M3'
annotationProcessor "org.androidannotations:androidannotations:$AAVersion"
implementation "org.androidannotations:androidannotations-api:$AAVersion"
annotationProcessor "org.androidannotations:rest-spring:$AAVersion"
implementation "org.androidannotations:rest-spring-api:$AAVersion"
annotationProcessor "org.androidannotations:otto:$AAVersion"
implementation "org.androidannotations:otto:$AAVersion"
implementation 'com.github.bumptech.glide:glide:3.7.0'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:recyclerview-v7:26.1.0'
// support AA on Android < 5
// compile 'com.android.support:multidex:1.0.1'
implementation 'com.github.markomilos:paginate:0.5.1'
// mpandroid
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.0-beta1'
// crashlytics fabric
implementation('com.crashlytics.sdk.android:crashlytics:2.6.1#aar') {
transitive = true
}
// recaptcha
implementation ('android.lib.recaptcha:reCAPTCHA:2.0.0') {
exclude group: 'com.android.support'
}
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.9.0'
}

I have solved opening modules project one by one and doing this for each one:
Project Structure -> Project -> Gradle Version = 4.7
Settings -> Build, Execution, Deployment -> Compiler -> Uncheck "Configure on demand"
Rebuild project once you can see your .aar file into build/outputs/aar
Then repeat these steps for main project module

Related

SafeArgs NavController Android gradle plugin update to 2.2.0 error

I was recently updating my App dependencies and when trying to update the safeargs navigation component gradle plugin to 2.2.1 (actually happens with 2.2.0 too) like this:
dependencies {
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.2.1"
...
}
I'm getting the following error when trying to compile the project:
Unable to find method 'com.squareup.kotlinpoet.ClassName.<init>(Ljava/lang/String;[Ljava/lang/String;)V'.
Possible causes for this unexpected error include:
Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)
The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
Stop Gradle build processes (requires restart)
Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.
In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
I tried all those solutions, none worked.
Gradle Files
build.gradle(project)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.71'
ext.navControllerVersion = '2.1.0'
ext.apolloVersion = '1.4.3'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "com.apollographql.apollo:apollo-gradle-plugin:$apolloVersion"
classpath 'com.google.gms:google-services:4.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
//Plugin added to check if the project has the last dependencies. You can run a gradle task via terminal with:
// ./gradlew dependencyUpdates
plugins {
id 'com.github.ben-manes.versions' version '0.28.0'
}
//This configuration is added for the ben-manes' plugin to ignore alpha, beta, rc, and so on updates
dependencyUpdates.resolutionStrategy {
componentSelection { rules ->
rules.all { ComponentSelection selection ->
boolean rejected = ['alpha', 'beta', 'rc', 'cr', 'm', 'preview'].any { qualifier ->
selection.candidate.version ==~ /(?i).*[.-]${qualifier}[.\d-]*/
}
if (rejected) {
selection.reject('Release candidate')
}
}
}
}
apply from: 'dependencies.gradle'
apply plugin: 'com.github.ben-manes.versions'
def versionMajor = 0
def versionMinor = 0
def versionPatch = 0
def versionBuild = 7 // bump for dogfood builds, public betas, etc.
allprojects {
repositories {
google()
jcenter()
}
ext {
androidApplicationId = 'es.client.mobile.android.appname'
androidVersionCode = versionMajor * 1000000 + versionMinor * 10000 + versionPatch * 100 + versionBuild
androidVersionName = "${versionMajor}.${versionMinor}.${versionPatch}.${versionBuild}"
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle(:app)
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: "androidx.navigation.safeargs.kotlin"
buildscript {
repositories {
google()
jcenter()
maven { url "https://salesforce-marketingcloud.github.io/MarketingCloudSDK-Android/repository" }
}
dependencies {
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$navControllerVersion"
}
}
android {
def globalConfiguration = rootProject.extensions.getByName("ext")
compileSdkVersion globalConfiguration["androidCompileSdkVersion"]
testOptions.unitTests.includeAndroidResources = true
defaultConfig {
minSdkVersion globalConfiguration["androidMinSdkVersion"]
targetSdkVersion globalConfiguration["androidTargetSdkVersion"]
applicationId globalConfiguration["androidApplicationId"]
versionCode globalConfiguration["androidVersionCode"]
versionName globalConfiguration["androidVersionName"]
testInstrumentationRunner "es.client.mobile.android.appname.app.test.TestRunner"
buildConfigField "String", "MC_APP_ID", MC_APP_ID
buildConfigField "String", "MC_ACCESS_TOKEN", MC_ACCESS_TOKEN
buildConfigField "String", "MC_SENDER_ID", MC_SENDER_ID
buildConfigField "String", "MC_MID", MC_MID
buildConfigField "String", "MC_SERVER_URL", MC_SERVER_URL
}
dexOptions {
javaMaxHeapSize "4g"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
packagingOptions {
exclude 'LICENSE.txt'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/ASL2.0'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
}
lintOptions {
quiet true
abortOnError false
ignoreWarnings true
disable 'GoogleAppIndexingWarning' //For removing warning about deep linking in Manifest, because this app do not use deep links
}
signingConfigs {
release {
keyAlias '###'
keyPassword '####'
storeFile file('../extras/release/bundle/###.jks')
storePassword '###'
}
}
buildTypes {
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
release {
signingConfig signingConfigs.release
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
flavorDimensions 'version'
productFlavors {
dev {
applicationIdSuffix ".dev"
versionNameSuffix "-dev"
dimension = 'version'
}
integDev {
applicationIdSuffix ".ind"
versionNameSuffix "-ind"
dimension = 'version'
}
integPre {
applicationIdSuffix ".inp"
versionNameSuffix "-inp"
dimension = 'version'
}
pro {
applicationIdSuffix ".pro"
versionNameSuffix "-pro"
dimension = 'version'
}
}
dataBinding {
enabled = true
}
}
androidExtensions {
experimental = true
}
dependencies {
def appDependencies = rootProject.ext.appDependencies
def appTestDependencies = rootProject.ext.appTestDependencies
def developmentDependencies = rootProject.ext.developmentDependencies
implementation project(':model')
implementation project(':domain')
implementation project(':data')
implementation project(':datasources')
implementation appDependencies.kotlin
implementation appDependencies.koin
implementation appDependencies.koinCompile
implementation appDependencies.koinArch
implementation appDependencies.ktxCore
implementation appDependencies.androidAnnotation
implementation appDependencies.appcompat
implementation appDependencies.recyclerView
implementation appDependencies.constraintLayout
implementation appDependencies.materialDesign
implementation appDependencies.lifecycleExtensions
implementation appDependencies.lifecycleCommonJava8
implementation appDependencies.navigationFragment
implementation appDependencies.navigationUi
implementation appDependencies.roomRuntime
implementation appDependencies.rxJava
implementation appDependencies.rxAndroid
implementation appDependencies.rxKotlin
implementation appDependencies.glide
implementation appDependencies.timber
implementation appDependencies.googleMaps
implementation appDependencies.googleMapsUtils
implementation appDependencies.googleLocation
implementation appDependencies.viewpager2
implementation appDependencies.playServicesAuth
implementation appDependencies.facebookSdk
implementation appDependencies.firebaseAnalytics
implementation appDependencies.firebaseCore
implementation appDependencies.firebaseMessaging
implementation appDependencies.marketingCloud
implementation appDependencies.googleServices
implementation appDependencies.zXing
implementation appDependencies.zXingEmbedded
// Unit test dependencies
implementation 'androidx.appcompat:appcompat:1.1.0'
testImplementation appTestDependencies.kotlinJUnit
testImplementation appTestDependencies.mockitoKotlin
testImplementation appTestDependencies.mockitoInline
// Instrumentation test dependencies
androidTestImplementation appTestDependencies.junit
androidTestImplementation appTestDependencies.lifecycleTest
androidTestImplementation(appTestDependencies.koinTest, {
exclude group: 'org.jetbrains.kotlin'
exclude group: 'org.mockito'
})
androidTestImplementation(appTestDependencies.mockitoKotlin, {
exclude group: 'org.jetbrains.kotlin'
exclude group: 'org.mockito'
})
androidTestImplementation appTestDependencies.mockitoAndroid
androidTestImplementation appTestDependencies.androidJUnit
androidTestImplementation(appTestDependencies.espressoCore) {
exclude group: 'com.android.support', module: 'support-annotations'
}
androidTestImplementation(appTestDependencies.androidRunner) {
exclude group: 'com.android.support', module: 'support-annotations'
}
androidTestImplementation(appTestDependencies.androidRules) {
exclude group: 'com.android.support', module: 'support-annotations'
}
androidTestImplementation(appTestDependencies.espressoIntents) {
exclude group: 'com.android.support', module: 'support-annotations'
}
androidTestImplementation(appTestDependencies.espressoContrib) {
exclude module: 'appcompat'
exclude module: 'appcompat-v7'
exclude module: 'support-v4'
exclude module: 'support-v13'
exclude module: 'support-annotations'
exclude module: 'recyclerview-v7'
exclude module: 'design'
}
//Development
debugImplementation developmentDependencies.leakCanary
debugImplementation developmentDependencies.flipper
debugImplementation developmentDependencies.soloader
debugImplementation developmentDependencies.flipperLeakcanary
}
apply plugin: 'com.google.gms.google-services' // Google Play services Gradle plugin
Edit:
More debug lead me to the conclusion that this is being caused by a dependency conflict on the kotlinpoet library, because if I change the safe-args plugin to use the java version:
apply plugin: "androidx.navigation.safeargs"
it works as expected. My problem is that when I invoke ./gradlew app:dependencies I'm not getting any dependency on kotlinpoet, so I don't know how to debug the conflict.
Thanks and best regards,
Ignacio
You've got the code below in your gradle module app instead of having it in gradle project.
Try this:
gradle project:
repositories {
google()
jcenter()
maven { url "https://salesforce-marketingcloud.github.io/MarketingCloudSDK-Android/repository" }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "com.apollographql.apollo:apollo-gradle-plugin:$apolloVersion"
classpath 'com.google.gms:google-services:4.3.3'
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$navControllerVersion"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
And remove this:
gradle module:
buildscript {
repositories {
google()
jcenter()
maven { url "https://salesforce-marketingcloud.github.io/MarketingCloudSDK-Android/repository" }
}
dependencies {
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$navControllerVersion"
}
}
In some cases the issue might be related to an old version of kotlinpoet conflicting with kotlinpoet version included in the SafeArgs lib.
Updating kotlinpoet to 1.4.4 solves the issue.

After upgrade gradle : Program type already present: net.jcip.annotations.GuardedBy

After i upgrade gradle, also gms, i'm having a error
Program type already present: net.jcip.annotations.GuardedBy
Message{kind=ERROR, text=Program type already present: net.jcip.annotations.GuardedBy, sources=[Unknown source file], tool name=Optional.of(D8)}
apply plugin: 'com.android.application'
configurations {
all*.exclude group: 'com.android.support', module: 'support-v4'
}
buildscript {
repositories {
jcenter()
mavenCentral()
}
}
def AAVersion = '4.6.0' // change this to your desired version, for
example the latest stable: 4.1.0
android {
signingConfigs {
config {
keyAlias 'toefl2017'
keyPassword 'sangohan1987'
storePassword 'sangohan1987'
}
}
compileSdkVersion 28
buildToolsVersion "28.0.0"
defaultConfig {
applicationId "com.ouamassi.widaf"
minSdkVersion 14
targetSdkVersion 28
versionCode 5
versionName "1.03"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
javaCompileOptions{
annotationProcessorOptions{
includeCompileClasspath = true
}
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
release {
minifyEnabled false
debuggable false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
}
debug {
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/license.txt'
exclude 'META-INF/LGPL2.1'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation ('com.android.billingclient:billing:1.2.2')
implementation ("org.androidannotations:androidannotations:$AAVersion")
implementation ("org.androidannotations:androidannotations-api:$AAVersion")
implementation ('com.google.android.gms:play-services:12.0.0')
implementation project(path: ':fivestarslibrary', configuration: 'default')
}
Where is this GuardedBy thing ? i search for it but i don't found nothing
Generic gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.1'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
classpath 'com.google.gms:google-services:3.1.0'
// 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
}
any help would be appreciated
With this :
./gradlew app:dependencies
I get detail of dependencies so i detect that the problem come from androidannotations
so instead of :
implementation ("org.androidannotations:androidannotations:$AAVersion")
implementation ("org.androidannotations:androidannotations-api:$AAVersion")
i had to put :
annotationProcessor ("org.androidannotations:androidannotations:$AAVersion")
implementation ("org.androidannotations:androidannotations-api:$AAVersion")
and also add :
multiDexEnabled true
implementation 'com.android.support:multidex:1.0.3'

Multiple dex files define Lcom/google/protobuf/AbstractMessageLite$Builder$LimitedInputStream;

I downloaded this sample speech-to-text project:
https://github.com/GoogleCloudPlatform/android-docs-samples/tree/master/speech
The project is working fine. However, I want to add the text-to-speech functionality. Whenever I try to compile com.google.cloud:google-cloud-texttospeech:0.70.0-beta I get the following error and the project crashes:
Multiple dex files define Lcom/google/protobuf/AbstractMessageLite$Builder$LimitedInputStream;
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
Here's my app's build.gradle:
apply plugin: 'com.google.protobuf'
apply plugin: 'com.android.application'
ext {
supportLibraryVersion = '25.4.0'
grpcVersion = '1.4.0'
}
android {
compileSdkVersion 25
flavorDimensions "default"
defaultConfig {
applicationId "com.google.cloud.android.speech"
targetSdkVersion 25
versionCode 1
versionName '1.0'
multiDexEnabled true
}
signingConfigs {
release {
storeFile file(project.properties.storeFile)
storePassword project.properties.storePassword
keyAlias project.properties.keyAlias
keyPassword project.properties.keyPassword
}
}
productFlavors {
dev {
dimension "default"
// Minimum version with platform multi-dex support
minSdkVersion 21
}
prod {
dimension "default"
// Minimum version that can run gRPC (TLS extension)
minSdkVersion 16
}
}
buildTypes {
debug {
minifyEnabled false
multiDexEnabled true
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
configurations.all {
resolutionStrategy.force 'com.google.code.findbugs:jsr305:3.0.2'
resolutionStrategy.force "com.android.support:support-annotations:$supportLibraryVersion"
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
exclude 'META-INF/INDEX.LIST'
}
}
protobuf {
protoc {
artifact = 'com.google.protobuf:protoc:3.3.0'
}
plugins {
javalite {
artifact = "com.google.protobuf:protoc-gen-javalite:3.0.0"
}
grpc {
artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}"
}
}
generateProtoTasks {
all().each { task ->
task.plugins {
javalite {}
grpc {
// Options added to --grpc_out
option 'lite'
}
}
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
// UI-related libraries
implementation 'com.skyfishjy.ripplebackground:library:1.0.1'
// Support libraries
implementation "com.android.support:design:$supportLibraryVersion"
implementation "com.android.support:cardview-v7:$supportLibraryVersion"
implementation "com.android.support:recyclerview-v7:$supportLibraryVersion"
// gRPC
implementation "io.grpc:grpc-okhttp:$grpcVersion"
implementation "io.grpc:grpc-protobuf-lite:$grpcVersion"
implementation "io.grpc:grpc-stub:$grpcVersion"
implementation 'javax.annotation:javax.annotation-api:1.2'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
protobuf 'com.google.protobuf:protobuf-java:3.6.1'
// OAuth2 for Google API
implementation('com.google.auth:google-auth-library-oauth2-http:0.7.0') {
exclude module: 'httpclient'
}
// Tests
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:0.5'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:2.2.2'
implementation ('com.google.cloud:google-cloud-texttospeech:0.70.0-beta'){
exclude module: 'httpclient'
}
compile 'com.android.support:multidex:1.0.3'
}
task copySecretKey(type: Copy) {
def File secretKey = file "$System.env.GOOGLE_APPLICATION_CREDENTIALS"
from secretKey.getParent()
include secretKey.getName()
into 'src/main/res/raw'
rename secretKey.getName(), "credential.json"
}
preBuild.dependsOn(copySecretKey)

Android Build Ends With 704 Errors But App Works

I have got an awkward problem on my Android App. When i build my app on Android Studio, build ends with 704 errors but app works on my test device correctly. I can't figured out the problem. I searched on Google and found some answers in stackoverflow but they did not help me. Because i don't use proguard right know on my project and the answers are all about proguard.
And below codes are my app level 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'
apply plugin: 'com.google.gms.google-services'
repositories {
maven {
url "http://dl.bintray.com/piasy/maven"
}
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "***.***.***"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
buildConfigField 'Boolean', 'crashlyticsEnabled', 'true'
buildConfigField 'Boolean', 'logEnabled', 'true'
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
buildConfigField 'Boolean', 'crashlyticsEnabled', 'true'
buildConfigField 'Boolean', 'logEnabled', 'false'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
exclude 'META-INF/rxjava.properties'
}
dexOptions {
javaMaxHeapSize "4g" //specify the heap size for the dex process
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.1'
compile "com.android.support:recyclerview-v7:23.1.1"
compile 'com.google.android.gms:play-services-gcm:8.3.0'
compile project(':chatlibrary')
compile 'com.amazonaws:aws-android-sdk-sns:2.2.14'
compile 'com.norbsoft.typefacehelper:library:0.9.0'
compile 'com.github.piasy:rxscreenshotdetector:1.1.0'
compile('com.crashlytics.sdk.android:crashlytics:2.6.7#aar') {
transitive = true;
}
compile('com.digits.sdk.android:digits:2.0.6#aar') {
transitive = true;
}
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:recyclerview-v7:23.0.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.google.android.gms:play-services-location:8.3.0'
compile 'com.google.android.gms:play-services-maps:8.3.0'
compile 'com.github.GDG-Korea:PinterestLikeAdapterView:29697e2c24'
}
Thanks for your helps...

Android Studio with Robolectric: my class test is not found

This is my gradle file:
apply plugin: 'android'
apply plugin: 'android-test'
android {
// Check on it to know witch Android API level is necessary:
// http://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels
compileSdkVersion 19
buildToolsVersion '19.0.1'
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
versionCode 1
versionName "1.0"
testInstrumentationRunner "com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
sourceSets {
androidTest {
setRoot('src/test')
}
}
// Patch: http://stackoverflow.com/questions/20673888/duplicate-files-copied-android-studio-0-4-0
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
}
}
androidTest {
include '**/*Test.class'
exclude '**/espresso/**/*.class'
}
dependencies {
// Android SDK Extra librairies
compile 'com.android.support:support-v4:19.0.+'
compile 'com.android.support:appcompat-v7:19.0.+'
compile fileTree(dir: 'libs', include: ['*.jar'])
// Android testing
// http://robolectric.org/
androidTestCompile 'junit:junit:4.+'
androidTestCompile 'org.robolectric:robolectric:2.+'
androidTestCompile 'com.squareup:fest-android:1.0.+'
// had to deploy to sonatype to get AAR to work
//compile 'com.novoda:actionbarsherlock:4.3.2-SNAPSHOT'
}
This my root gradle file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
maven { url "http://dl.bintray.com/populov/maven" }
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
//classpath 'com.neenbedankt.gradle.plugins:android-apt:1.2+'
//classpath 'com.novoda.gradle:robolectric-plugin:0.0.1-SNAPSHOT'
classpath 'org.robolectric.gradle:gradle-android-test-plugin:0.10.+'
}
}
allprojects {
repositories {
maven { url "http://dl.bintray.com/populov/maven" }
mavenCentral()
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
}
}
I just write an easy class to test to validate my infrastructure test, but I have this error:
Class not found: "com.example.myapp.activity.BaseActivityTest"
My test class is:
package com.example.myapp.activity;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import static org.junit.Assert.*;
#RunWith(RobolectricTestRunner.class)
public class BaseActivityTest {
#Test
public void testTrueIsTrue() throws Exception {
assertEquals(true, true);
}
}
My folder architecture is:
myapp
src
main
java
com.example.myapp ...
test
java
com.example.myapp ...
I don't understand why this error appears.
Ok guys, I found a solution:
This is my gradle file:
apply plugin: 'android'
apply plugin: 'robolectric'
android {
// Check on it to know witch Android API level is necessary:
// http://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels
compileSdkVersion 19
buildToolsVersion '19.0.1'
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
versionCode 1
versionName "1.0"
testInstrumentationRunner "com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
sourceSets {
androidTest {
setRoot('src/test')
}
}
}
// prevent the "superClassName is empty" error for classes not annotated as tests
tasks.withType(Test) {
scanForTestClasses = false
include "**/*Test.class" // whatever Ant pattern matches your test class files
}
dependencies {
// Android SDK Extra librairies
compile 'com.android.support:support-v4:19.0.+'
compile 'com.android.support:appcompat-v7:19.0.+'
compile fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
// Android testing
//androidTestCompile configurations.androidTestCompile.dependencies
// http://robolectric.org/
androidTestCompile 'org.robolectric:robolectric:2.+'
androidTestCompile 'junit:junit:4.+'
}
And I modified my VM argument (Configuration edition) like this post: http://blog.futurice.com/android_unit_testing_in_ides_and_ci_environments

Categories

Resources