module was not opening using dynamic feature in android - android

I am working on the dynamic feature module. I uploaded the .aab file into playstore some times app is unable to open the module throwing the error like this.
This is the error getting in logcat:
PID: 12715
java.lang.RuntimeException: Unable to instantiate activity
ComponentInfo{com.testDynamic/com.testDynamic.zco.ZcoActivity}:
java.lang.ClassNotFoundException: Didn't find class
"com.testDynamic.zco.ZcoActivity"
on path: DexPathList[[zip file
"/data/app/com.testDynamic-1/base.apk",
This issue here is my code.
This is my Main app manifest file:
<?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.testDynamic">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<dist:module dist:instant="true" />
<application
android:name=".Application"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Here is my module Manifest:
<?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.testDynamic.zco"
split="dynamiczco">
<dist:module
dist:onDemand="true"
dist:title="#string/title_test">
<dist:fusing dist:include="true" />
</dist:module>
<application>
<activity
android:name="com.testDynamic.module.ZcoActivity"
android:label="#string/title_activity_test"
android:theme="#style/AppTheme.NoActionBar">
</activity>
</application>
</manifest>
Here is my main gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.testDynamic"
minSdkVersion 23
targetSdkVersion 27
versionCode 33
versionName "3.1"
}
dynamicFeatures = [":dynamicmodule",":dynamic_feature2",":dynamiczco"]
compileOptions {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
}
dependencies {
api fileTree(dir: 'libs', include: ['*.jar'])
api 'com.android.support:appcompat-v7:27.1.1'
api 'com.android.support:recyclerview-v7:27.1.1'
api 'com.google.android.play:core:1.3.1'
api 'com.android.support.constraint:constraint-layout:1.1.2'
api 'com.squareup.retrofit2:retrofit:2.1.0'
api 'com.squareup.retrofit2:converter-gson:2.1.0'
api 'com.android.support:cardview-v7:27.1.1'
}
Here is my module gradle:
apply plugin: 'com.android.dynamic-feature'
android {
compileSdkVersion 27
defaultConfig {
minSdkVersion 20
targetSdkVersion 27
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':app')
// implementation 'com.google.android.material:material:27.0.+'
}
Anyone have an idea about this error please help me to resolve
Anyone help to solve this issue.
Thanks in advance.

Hi after researching i got the solution. Now the module was downloading without any crash.
I changed the module manifest
<dist:module
dist:onDemand="true"
dist:title="#string/title_test">
<dist:fusing dist:include="true" />
to
<dist:module
dist:instant="true"
dist:onDemand="false"
dist:title="#string/title_test">
<dist:fusing dist:include="true" />
</dist:module>
It is working fine.
Thank you all

Related

Error: Program type already present: com.getcapacitor.AndroidProtocolHandler

I want to generate APK of the ionic app but I am getting
Program type already present: com.getcapacitor.AndroidProtocolHandler
error while building the ionic 4 app with angular. I have searched this on the internet and find one solution which says change
implementation 'ionic-team:capacitor-android:1+'
to
implementation project(':capacitor-android')"
in dependencies in build.gradle file but I already have implementation project(':capacitor-android')" in my dependency and I'm still getting the error.
This is link to the solution I have tried: https://github.com/oxylian/capacitor-facebook-login/issues/3
This is my build.gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "io.ionic.starter"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
maven {
url "https://dl.bintray.com/ionic-team/capacitor"
}
flatDir{
dirs '../capacitor-cordova-android-plugins/src/main/libs', 'libs'
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation project(':capacitor-android')
// implementation 'ionic-team:capacitor-android:1+'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation project(':capacitor-cordova-android-plugins')
}
apply from: 'capacitor.build.gradle'
try {
def servicesJSON = file('google-services.json')
if (servicesJSON.text) {
apply plugin: 'com.google.gms.google-services'
}
} catch(Exception e) {
logger.warn("google-services.json not found, google-services plugin not applied. Push Notifications won't work")
}
This is my AndroidManifest.xml file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="io.ionic.starter">
<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:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale"
android:name="io.ionic.starter.MainActivity"
android:label="#string/title_activity_main"
android:theme="#style/AppTheme.NoActionBarLaunch"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="#string/custom_url_scheme" />
</intent-filter>
</activity>
<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"></meta-data>
</provider>
</application>
<!-- Permissions -->
<uses-permission android:name="android.permission.INTERNET" />
<!-- Camera, Photos, input file -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- Geolocation API -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-feature android:name="android.hardware.location.gps" />
<!-- Network API -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- Navigator.getUserMedia -->
<!-- Video -->
<uses-permission android:name="android.permission.CAMERA" />
<!-- Audio -->
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
</manifest>
The problem is the date picker plugin, it has that line that you have mentioned
https://github.com/triniwiz/capacitor-datepicker/blob/master/src/android/capacitor-datepicker/build.gradle#L45
There is a pull request fixing it, but hasn’t been merged
https://github.com/triniwiz/capacitor-datepicker/pull/12

app:transformClassesWithDexForDebug exception and java.util.concurrent.ExecutionException

I am getting below Error while running my Application.
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
I think the issue is with my .gradle file. Maybe some duplication for dependency in my .gradle file. I have removed one but, still getting the error.
My .gradle file is as below.
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.mypackagename"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:multidex:1.0.0'
compile 'com.android.support:appcompat-v7:25.0.1'
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha8'
compile 'com.google.android.gms:play-services:11.0.2'
compile 'com.android.support:design:25.0.0'
compile 'com.android.support:recyclerview-v7:25.0.1'
testCompile 'junit:junit:4.12'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.android.support:cardview-v7:24.2.+'
compile 'com.google.code.gson:gson:2.6.1'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'com.squareup.okhttp:okhttp:2.6.0'
compile 'com.google.firebase:firebase-auth:11.0.2'
compile 'com.google.android.gms:play-services-auth:11.0.2'
}
}
My Manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mypackagename">
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="com.roadysmart.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".SplashActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:screenOrientation="portrait"
android:theme="#style/AppTheme.NoActionBar"></activity>
<activity
android:name=".UserProfileEditActivity"
android:label="User Profile"
android:screenOrientation="portrait" />
<activity
android:name=".SignInActivity"
android:label="Sign In"
android:screenOrientation="portrait" />
<activity
android:name=".SelectActivity"
android:label="Were here to help"
android:screenOrientation="portrait" />
<activity
android:name=".SignUpActivity"
android:label="Sign Up"
android:screenOrientation="portrait" />
<activity
android:name=".ForgotPasswordActivity"
android:label="Forgot Password"
android:screenOrientation="portrait" />
<activity
android:name=".UserProfileActivity"
android:label="User Profile"
android:screenOrientation="portrait" />
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="AIzaS0000000014789occURS5KvtKgfdreWjaDI" />
</application>
Try adding multiDexEnabled true in defaultConfig.
Moreover, its not recommended to use com.google.android.gms:play-services:11.0.2 directly rather include the dependencies you want to work with separately. Like if you want to work with Google Maps, then add only com.google.android.gms:play-services-maps:11.1.0 and so on.
com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
You've hit the dex limit for the number of methods that can be used in which affects all device lower than Android 5.0(21).
To fix this you need to enable multi-dex in your gradle and have your application extends MultiDexApplication to work around with the max Dex limit.
android {
defaultConfig {
...
minSdkVersion 21
targetSdkVersion 26
multiDexEnabled true
}
...
}

MapBox SDK not working android

I just started to use the MapBox SDK but its not working I was following the steps on the documentation but Im not getting any classes from their SDK here is my code:
build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.1"
defaultConfig {
applicationId "com.mapp.hello"
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.2.0'
compile ('com.mapbox.mapboxsdk:mapbox-android-sdk:4.2.0-beta.2#aar'){
transitive=true
}
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.mapp.hello"
xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
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.mapbox.mapboxsdk.telemetry.TelemetryService"/>
</application>
</manifest>
The com.mapbox.mapboxsdk.telemetry.TelemetryService is shown in red and I cannot import the MapboxAccountManager
I know it's an old question, but I just had the same error while trying to update from Mapbox 4.x to 5.x and it turns out you have to change:
<service android:name="com.mapbox.mapboxsdk.telemetry.TelemetryService"/>
to
<service android:name="com.mapbox.services.android.telemetry.service.TelemetryService" />
Update:
Turns out in the latest version (5.x) you don't have to declare it in the Manifest at all, as Mapbox now makes use of Manifest merge feature.
I dont know how but the app was getting run even though gradle build was stopped because of lint, I just stopped lint from stopping the build process now everything is working :)

Error .dex exceeds 64k android studio

When i try to run the program, i get error exceeds 64k
I don't know how to solve this. I had already try the resolve but it still failed and give me more error. Please help me
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.example.timslbl.geogencybaru"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:multidex:1.0.0'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:cardview-v7:23.2.1'
compile 'com.roughike:bottom-bar:1.2.1'
compile 'com.google.http-client:google-http-client-android:+'
compile 'com.google.api-client:google-api-client-android:+'
compile 'com.google.api-client:google-api-client-gson:+'
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.android.support:support-v4:23.2.1'
}
Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.timslbl.geogencybaru">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- Required to show current location -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<!-- Required OpenGL ES 2.0. for Maps V2 -->
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<aplication
android:name="android.support.multidex.MultiDexApplication"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".SplashActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="" />
<activity android:name=".MapActivity" />
<activity android:name=".MainActivity"></activity>
<activity android:name=".LoginActivity"></activity>
<activity android:name=".RegisterActivity"></activity>
</aplication>
</manifest>
This is the error that i got after try the resolve
I highly suggest not to compile compile 'com.google.android.gms:play-services:8.4.0'
as it is,
Which is one of the main cause of 64K method dex limit.
The separate compilations beyond play-services itself is listed Here, Use the one you really need rather than compiling the whole play-services.
Is your project a very large one? I'm suspecting that it may be going over the method limit of 64k. Have a look at this documentation. It may help.

any suggest? Failure [INSTALL_FAILED_OLDER_SDK]

my build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.example.vladxd.trackingpoint_2"
minSdkVersion 21
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v13:22.0.0'
compile 'com.android.support:support-v4:22.0.0'
compile 'com.google.android.gms:play-services:7.0.0'
}
and here is my Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.vladxd.trackingpoint" >
<!-- To access Google+ APIs: -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.vladxd.trackingpoint.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>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyB5HcvlWp6AAUBU65Iq7CC_huQi_yK1XG8" />
</application>
</manifest>
Do u have any idea how I can solve it? I've try to find this problem on another post from stackoverflow but all that don't work for me... and I don't know why.
So if u have any idea pls told me :D
Sry for my bad english.
The gradle file sets the build to be minSdk of 21 which is Android 5.0. The error is basically saying that the device you're attempting to install on has an older os.
If go into the device settings -> About Phone there should be an entry that shows your Android Version. That should then line up with the values from http://developer.android.com/reference/android/os/Build.VERSION_CODES.html

Categories

Resources