Dexguard error while running signed apk - android

I am using Android Studio,my project has 5 modules.
While running signed obfuscated apk I am getting the following error
Unable to instantiate application com.....FTApplication: java.lang.ClassNotFoundException: Didn't find class "com....FTApplication" on path: DexPathList[[zip file "/data/app/app.apk"].
This is my configuration
DexGuard6.1.03
com.android.tools.build:gradle:1.0.0 - dependency
Application extends from MultiDexApplication.
Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.project.package">
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:name="com.project.package.FTApplication"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<activity
android:name=".ui.activity.FTSplashActivity"
android:label="#string/app_name"
android:noHistory="true"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
top-level build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
module build.grade
apply plugin: 'com.android.application'
apply plugin: 'dexguard'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
buildscript {
repositories {
mavenCentral()
flatDir { dirs '../../DexGuard6.1.03/lib' }
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
classpath ':dexguard:'
}
}
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.project.package"
minSdkVersion 17
targetSdkVersion 21
versionCode 1
versionName "1.0"
multiDexEnabled = true
}
buildTypes {
debug {
proguardFile getDefaultDexGuardFile('dexguard-debug.pro')
proguardFile 'dexguard-project.txt'
}
release {
proguardFile getDefaultDexGuardFile('dexguard-release.pro')
proguardFile 'dexguard-project.txt'
}
// release {
// minifyEnabled false
// proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
// }
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':materialdialogs')
compile project(':AndroidKit')
compile 'com.joanzapata.pdfview:android-pdfview:1.0.4#aar'
compile files('libs/disklrucache-2.0.1.jar')
compile 'com.android.support:multidex:1.0.1'
compile 'com.jakewharton:disklrucache:2.0.2'
compile files('libs/commons-httpclient-3.0.jar')
compile files('libs/httpclientandroidlib-1.2.1.jar')
}

Thanks to #John for the comment.
Here is the solution for MultiDex with Dexguard:
1) Apply default MultiDex rules correctly. See my another post for correct options.
2) Modify build.gradle and dexguard-project.txt files.
build.gradle : Set multiDexEnabled true only for debug builds. Dexguard is going to handle it at release build.
defaultConfig {
applicationId "com.sample"
minSdkVersion 14
targetSdkVersion 22
versionCode 1
versionName "1.0"
// NOTE 1 : Remove multiDexEnabled setting from here
}
buildTypes {
debug {
// NOTE 2 : By default, debug builds don't need Dexguard. So set multiDexEnabled here.
multiDexEnabled true
}
release {
// NOTE 3 : Multidex is handled at dexguard-project.txt. So remove multiDexEnabled setting if exists.
proguardFiles getDefaultDexGuardFile('dexguard-release.pro'),'dexguard-project.txt'
}
}
dexguard-project.txt : Do not forget to add multidex option here!
-multidex

Related

Build fails with 'task :features:catalog:createDebugCompatibleScreenManifests FAILED' while refactoring to dynamic feature modules on android

Once I introduced dynamic feature modules into my app, I was able to successfully refactor feature one (orders), build and deploy. But on refactoring the second module, i.e moving files and resources to that module, I get this error on build:
Execution failed for task ':features:catalog:createDebugCompatibleScreenManifests'.
> Failed to calculate the value of task ':features:catalog:createDebugCompatibleScreenManifests' property 'applicationId'.
> Failed to query the value of property 'testedApplicationId'.
> Collection has more than one element.
I have tried the following fixes:
invalidate cache
reclone project
ensure all gradle files are identical (except for applicationId bit)
checked that there are no errors in the manifest files
confirmed that no two modules share the same application ID.
rebase the project to the last working commit.
Any pointers as to what is causing this build issue?
Other info: I'm using dependency injection with koin.
App/Main module manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.app">
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-feature
android:name="android.hardware.camera2"
android:required="false" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:name=".ExampleApp"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:networkSecurityConfig="#xml/network_security_config"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme"
tools:ignore="AllowBackup,GoogleAppIndexingWarning">
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="#string/google_maps_key" />
<meta-data
android:name="firebase_crashlytics_collection_enabled"
android:value="${crashlyticsCollectionEnabled}" />
<activity android:name="com.kyosk.app.ui.fragment.login.LoginActivity" />
<activity android:name="com.kyosk.app.ui.activity.SplashActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.kyosk.app.ui.activity.Home" />
<service
android:name=".service.MessagingService"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<service
android:name=".location.services.LocationUpdatesService"
android:exported="false" />
<service
android:name=".location.services.MapsLocationUpdatesService"
android:exported="false" />
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="#xml/file_paths" />
</provider>
</application>
</manifest>
App/Main module build.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: "androidx.navigation.safeargs.kotlin"
apply plugin: 'realm-android'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
apply plugin: (BuildPlugins.dependencyUpdateChecker)
android {
compileSdkVersion AndroidSDK.compileSDKVersion
buildToolsVersion Versions.buildTools
defaultConfig {
applicationId "com.example.app"
minSdkVersion AndroidSDK.minimumSDKVersion
targetSdkVersion AndroidSDK.targetSDKVersion
versionCode Versions.versionCode
versionName Versions.versionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
debug {
manifestPlaceholders = [crashlyticsCollectionEnabled: "false"]
applicationIdSuffix(".debug")
versionNameSuffix("-debug")
buildConfigField("String", "BASE_URL", debug_url)
}
staging {
initWith(release)
manifestPlaceholders = [crashlyticsCollectionEnabled: "false"]
applicationIdSuffix(".staging")
versionNameSuffix("-staging")
buildConfigField("String", "BASE_URL", staging_url)
}
release {
manifestPlaceholders = [crashlyticsCollectionEnabled: "true"]
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
buildConfigField("String", "BASE_URL", production_url)
}
}
buildFeatures {
viewBinding = true
dataBinding = true
}
kotlinOptions {
jvmTarget = '1.8'
}
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
kapt {
correctErrorTypes = true
}
dynamicFeatures = [':features:kiosks', ':features:catalog', ':features:checkout', ':features:summary', ':features:orders']
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation Libraries.kotlinStandardLibrary
implementation Libraries.appCompat
implementation Libraries.constraintLayout
api Libraries.materialComponents
implementation Libraries.navigationFragment
implementation Libraries.navigationUI
implementation Libraries.preferences
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
//firebase libs
implementation Libraries.firebaseMessaging
implementation Libraries.firebaseConfig
// Recommended: Add the Firebase SDK for Google Analytics.
implementation Libraries.firebaseAnalytics
implementation Libraries.firebaseCrashlytics
// DI
api Libraries.koinAndroid
api Libraries.koinLifecycle
api Libraries.koinViewmodel
//maps
implementation 'com.google.android.gms:play-services-maps:17.0.0'
//own modules
implementation project(path: ':location-services')
implementation project(path: ':network')
api project(path: ':helpers')
//glide
implementation 'com.github.bumptech.glide:glide:4.11.0'
kapt 'com.github.bumptech.glide:compiler:4.11.0'
//loading button
api Libraries.buttonProgress
//pagination lib
implementation Libraries.jdroidCoder
//EventBus
api Libraries.eventBus
//logging
api Libraries.timber
//anko
api Libraries.ankoDesign
api Libraries.ankoCommons
//play core library
implementation(Libraries.playCore)
implementation(Libraries.playCorektx)
// paris for applying styles to views dynamically
implementation 'com.airbnb.android:paris:1.7.2'
// lottie for animations
implementation 'com.airbnb.android:lottie:3.5.0'
// Okhttp Profiler
implementation Libraries.loggingInterceptor
// Test libs
testImplementation(TestLibraries.junit4)
androidTestImplementation(TestLibraries.androidX)
androidTestImplementation(TestLibraries.espresso)
androidTestImplementation(TestLibraries.annotationLib)
}
Feature Module 1(orders) manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:dist="http://schemas.android.com/apk/distribution"
package="com.example.app.orders">
<dist:module
dist:instant="false"
dist:title="#string/title_orders">
<dist:delivery>
<dist:install-time />
</dist:delivery>
<dist:fusing dist:include="true" />
</dist:module>
</manifest>
Feature 1 (orders) build.gradle
apply plugin: 'com.android.dynamic-feature'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: (BuildPlugins.dependencyUpdateChecker)
android {
compileSdkVersion AndroidSDK.compileSDKVersion
buildToolsVersion Versions.buildTools
defaultConfig {
applicationId "com.example.app.orders"
minSdkVersion AndroidSDK.minimumSDKVersion
targetSdkVersion AndroidSDK.targetSDKVersion
versionCode Versions.versionCode
versionName Versions.versionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
debug {}
staging {}
release {}
}
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
viewBinding = true
dataBinding = true
}
}
dependencies {
implementation project(":app")
implementation project(path: ':network')
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation Libraries.kotlinStandardLibrary
implementation Libraries.ktxCore
implementation Libraries.appCompat
implementation Libraries.constraintLayout
implementation Libraries.materialComponents
implementation Libraries.navigationFragment
implementation Libraries.navigationUI
implementation Libraries.buttonProgress
implementation Libraries.ankoDesign
implementation Libraries.ankoCommons
implementation(Libraries.coroutinesAndroid)
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
// Test libs
testImplementation(TestLibraries.junit4)
androidTestImplementation(TestLibraries.androidX)
androidTestImplementation(TestLibraries.espresso)
androidTestImplementation(TestLibraries.annotationLib)
}
The issue ended up being a library I had imported.
The library had plugin apply plugin: 'com.android.application'
instead of
apply plugin: 'com.android.library'
As such, gradle build task was looking for applicationId and applicationName in the manifest, which was not there.
Oops, developer error.
For me it happened when adding a new dynamic feature module with multiple flavors.
I solved it by changing inside module.gradle:
implementation project(path: ':app', configuration: 'default')
into
implementation project(":app")
Then add flavors into module.gradle
flavorDimensions "app"
productFlavors {
flavor1 {}
flavor2 {}
flavor3 {}
}
Here is my final module.gradle
apply plugin: 'com.android.dynamic-feature'
android {
compileSdkVersion 29
buildToolsVersion '29.0.3'
defaultConfig {
minSdkVersion 21
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
flavorDimensions "app"
productFlavors {
flavor1 {}
flavor2 {}
flavor3 {}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation project(":app")
}
Uninstall the application from emulator and then restart it

Android Studio generated apk installs but doesn't open

I have installed my apk bundle that I created via Build APK(s) and it installs but won't let me open it, and it doesn't show in the menu.
I've already checked Project/App/src/main/AndroidManifest.xml and Project/build.gradle and settings.gradle as well but I don't find anything odd.
android:protectionLevel="signature" is not in any of the previous files.
minifyEnabled is FALSE
I've read somewhere to edit my manifest and add or something (I can't find the post right now). I did it, and the app began to have gradle errors, and showed me another manifest that had those lines written.
Here's my Project/App/src/main/AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.multicobertura">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.Multicobertura" />
</manifest>
build.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:4.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
}
settings.gradle
include ':app'
rootProject.name = "multicobertura"
I am clueless
EDIT: I tried adding "entry points"
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.multicobertura">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.Multicobertura" />
<activity
android:name=".NewEntryPoint"
android:label="#string/title_activity_second" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</manifest>
But
build.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:4.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
}
app build.gradle
plugins {
id 'com.android.application'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
defaultConfig {
applicationId "com.example.multicobertura"
minSdkVersion 16
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.1'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
EDIT2: I've already created a new android studio project, copied the files and yarn insalled the modules, built the app and failed as well. Anyone?

Getting error while generate the APK build and try to run it from device instant app

Instant app working FINE while run the app from android studio but, getting errors while generate the APK build and try to run it from device
getting below error in xiaomi noughat device
instant app crash by giving this message "There was a problem parsing the package"
I have used instant app development version 1.3.0 and also enabled instant app setting from settings > google > instant apps
E/Icon: Unable to load resource 0x00000000 from pkg=com.android.systemui
android.content.res.Resources$NotFoundException: Resource ID #0x0
at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:201)
at android.content.res.MiuiResourcesImpl.getValue(MiuiResourcesImpl.java:91)
at android.content.res.Resources.getDrawable(Resources.java:784)
at android.graphics.drawable.Icon.loadDrawableInner(Icon.java:316)
at android.graphics.drawable.Icon.loadDrawable(Icon.java:272)
at android.graphics.drawable.Icon.loadDrawableAsUser(Icon.java:380)
at com.android.systemui.statusbar.ExpandedIcon.getDrawable(ExpandedIcon.java:59)
at com.android.systemui.statusbar.StatusBarIconView.getIcon(StatusBarIconView.java:174)
at com.android.systemui.statusbar.StatusBarIconView.setIcon(StatusBarIconView.java:133)
at com.android.systemui.statusbar.StatusBarIconView.updateDarkMode(StatusBarIconView.java:266)
at com.android.systemui.statusbar.phone.SimpleStatusBar.updateDarkMode(SimpleStatusBar.java:264)
at com.android.systemui.statusbar.phone.PhoneStatusBar$17.run(PhoneStatusBar.java:3494)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6195)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:874)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:764)
and getting below error in lollipop device
package - Android: Parse error when parsing manifest. Discontinuing installation
Here i listed out manifest files and gradle files of my project
instantapp gradle
apply plugin: 'com.android.instantapp'
dependencies {
implementation project(':feature')
implementation project(':base')}
feature module gradle and manifest
apply plugin: 'com.android.feature'
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':base')
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myfirstinstantapp.feature">
<uses-permission android:name="android.permission.INTERNET" />
<application>
<activity android:name="com.example.myfirstinstantapp.feature.MainActivity">
<meta-data
android:name="default-url"
android:value="https://myfirstinstantapp.example.com/hello" />
<intent-filter android:order="1">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:host="myfirstinstantapp.example.com"
android:pathPattern="/.*"
android:scheme="https" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
===========================================
base module gradle and manifest
apply plugin: 'com.android.feature'
android {
compileSdkVersion 28
baseFeature true
defaultConfig {
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
api 'com.android.support:appcompat-v7:28.0.0-alpha3'
api 'com.android.support.constraint:constraint-layout:1.1.2'
application project(':app')
feature project(':feature')
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myfirstinstantapp">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity" />
</application>
</manifest>
===========================================
app gradle and manifest
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.myfirstinstantapp.app"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation project(':feature')
implementation project(':base')
}
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myfirstinstantapp.app" />
===========================================
project level gradle
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
// 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
}
Here i attached screenshot of my project structure

Android application on Gradle: Unable to merge dex

I have an error with my app in Android studio:
Execution failed for task
':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
I use Gradle and Kotlin.
Android Studio 3.0.1.
Windows 10 Pro 64.
I have research this theme on SO and I have tried some solution from here, like that:
Clean and rebuild project. No changes.
Change 'compile' in gradle to 'implementation'. No changes.
Delete .gradle and build directories. No changes.
Add multiDexEnabled true in defaultConfig in gradle. In this case, I have another error:
Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
> java.io.IOException: Can't write [G:\work\myapp\app\build\intermediates\multi-dex\debug\componentClasses.jar]
(Can't read [C:\Users\Public\.gradle\caches\transforms-1\files-1.1\support-core-utils-27.0.2.aar\e1c9881d763269b67bf59dc03d19c305\jars\classes.jar(;;;;;;**.class)]
(Duplicate zip entry [classes.jar:android/support/v4/content/PermissionChecker$PermissionResult.class]))
My build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 27
defaultConfig {
multiDexEnabled true
applicationId "myapp"
minSdkVersion 19
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
debug {
applicationIdSuffix ".dev"
}
staging {
debuggable true
applicationIdSuffix ".sta"
}
preproduction {
applicationIdSuffix ".pre"
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
jcenter()
mavenCentral()
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:27.0.2'
implementation 'com.basecamp:turbolinks:1.0.7'
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'
// The Client SDK resides on jCenter
implementation 'com.twilio:client-android:1.2.21'
}
My AndroidManifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.tunnll.passenger">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_SMS"/>
<uses-permission android:name="android.permission.RECEIVE_SMS"/>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name="com.twilio.client.TwilioClientService"
android:exported="false" android:stopWithTask="true"/>
</application>
What am I missing?
UPD
It seems I found out the point after that the problem has appeared. It was after adding Twilio configuration. I used this manual: Twilio and Android
This is all changes that have been done:
Add to build.gradle:
implementation 'com.twilio:client-android:1.2.21'
Add to AndroidManifest:
<service android:name="com.twilio.client.TwilioClientService"
android:exported="false" android:stopWithTask="true"/>
Add to proguard-rules.pro
# Twilio Client
-keep class com.twilio.** { *; }
# Apache HttpClient
-dontwarn org.apache.http.**
That's all. Before this changes I didn't have this error
Use this in your build.gradle in app Module if you want to read an .aar file
for your libs dir:
repositories{
flatDir{
dirs 'libs'
}
}
dependencies {
compile(name:'nameOfYourAARFileWithoutExtension', ext:'aar')
}
But it seems that your problem is multidex(means that you have more than 65K methods in your project so use this:
android {
defaultConfig {
multiDexEnabled true
}
}
and if your minSdk < 20 then use this as well:
compile 'com.android.support:multidex:1.0.1'
Hope it helps!!!

Git submodule causing Failure [INSTALL_FAILED_OLDER_SDK] Android sdk 21

I am working on an app and trying to use the new material design, aka sdk version 21.
I had everything working fine, and then wanted to at a fab (floating action button) using this library.
I added this library as a submodule, using
git submodule add https://github.com/shamanland/floating-action-button
while under C:\Users\USER\AndroidStudioProjects\ProjectName
My file structure looks like so
ProjectName
app
floating-action-button
The issue
Before everything was totally fine, I was able to build and run the project.
But, ever since adding this submodule, when trying to run it, I get the error
Failure [INSTALL_FAILED_OLDER_SDK]
So I'm thinking it has to do with the submodule, but I'm not sure how.
app/build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion '21.0.2'
defaultConfig {
applicationId "com.mayuonline.ribbit"
minSdkVersion 21
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:21.+'
compile 'com.android.support:cardview-v7:+'
compile 'com.android.support:recyclerview-v7:+'
compile 'com.android.support:palette-v7:+'
}
app/AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="resume.kelseyhrubes">
<uses-sdk tools:node="replace" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
f-a-b/build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.2'
classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.0'
classpath 'org.robolectric:robolectric-gradle-plugin:0.11.0'
}
}
def isSnapshot() {
return VERSION_NAME.contains('SNAPSHOT')
}
def gradleMvnPush = new File(buildDir, 'gradle-mvn-push.gradle')
if (!gradleMvnPush.exists()) {
buildDir.mkdirs()
ant.get(src: GRADLE_MVN_PUSH, dest: gradleMvnPush)
}
setProperty('GRADLE_MVN_PUSH', gradleMvnPush)
subprojects {
group GROUP
version VERSION_NAME
apply plugin: 'android-sdk-manager'
if (name.startsWith('lib')) {
apply plugin: 'com.android.library'
} else {
apply plugin: 'com.android.application'
}
android {
compileSdkVersion COMPILE_SDK_VERSION as int
buildToolsVersion BUILD_TOOLS_VERSION
defaultConfig {
minSdkVersion MIN_SDK_VERSION as int
targetSdkVersion TARGET_SDK_VERSION as int
versionCode 1
versionName '1.0'
// workaround for https://code.google.com/p/android/issues/detail?id=52962
buildConfigField 'boolean', 'SNAPSHOT', isSnapshot().toString()
}
lintOptions {
abortOnError false
}
}
repositories {
mavenLocal()
mavenCentral()
}
if (isSnapshot()) {
apply plugin: 'robolectric'
dependencies {
// NOTE workaround for sdkmanager plugin
compile 'com.android.support:support-v4:19.0.1'
androidTestCompile 'junit:junit:4.10'
androidTestCompile 'org.robolectric:robolectric:2.3'
androidTestCompile 'com.squareup:fest-android:1.0.8'
}
}
}
f-a-b/AndroidManifest.xml (probably a clue here, I (tried to) bold the areas that Android Studio has turned red
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=" **http://schemas.android.com/apk/res/android** "
package="com.shamanland.fab.example">
<application
android:name=" **.ExampleApplication** "
android:label="#string/app_name"
**android:icon** ="#drawable/ic_launcher"
**android:theme** ="#style/AppTheme"
**android:allowBackup** ="true"
>
<activity android:name=".ExampleListActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=" **.ExampleDetailsActivity** "/>
</application>
</manifest>
I have a strong suspicion that the submodule was added incorrectly.
Really all I want is to use a fab in my app, if anyone can help me figure out what may be wrong, with adding the submodule, or something with my build.gradle, that would really be appreciated!!
This error is usually caused by deploying an APK built with "compileSdkVersion n" to a device or emulator with an API level less than "n". Is your emulator at the right API level?

Categories

Resources