VM has multidex support, MultiDex support library is disabled - android

I'm getting the following error.
FATAL EXCEPTION: main
VM with version 2.1.0 has multidex support
install
VM has multidex support, MultiDex support library is disabled.
install
VM has multidex support, MultiDex support library is disabled.
Shutting down VM
here is my build.gradle,i have enables the multidex in the android part,
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.0'
defaultConfig {
applicationId "com.mycompany.newlogin"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
useLibrary 'org.apache.http.legacy'
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:multidex:1.0.0'
compile 'com.google.guava:guava-jdk5:17.0'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
//compile 'org.apache.httpcomponents:httpcore:4.4.1'
compile 'org.apache.httpcomponents:httpclient:4.5'
compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
}
and my manifest file is
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mycompany.newlogin" >
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme"
android:name="android.support.multidex.MultiDexApplication">
<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>
<activity
android:name=".Login"
android:label="#string/title_activity_login" >
</activity>
<activity
android:name=".Register"
android:label="#string/title_activity_register" >
</activity>
</application>
</manifest>

create a class lets name it App and extend from MultiDexApplication like this:
import android.support.multidex.MultiDexApplication;
public class App extends MultiDexApplication {
//you can leave this empty or override methods if you like so the thing is that you need to extend from MultiDexApplication
}
in your manifest add App as your application name just like this
<application
android:name=".App" // <<< this is the important line!
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name">
After adding everything make a clean build and it should work now :).

Override attachBaseContext method in your application class
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}

Related

Android plugin in Unity

i am trying to add a local .aar from an android library in Unity. Currently it is a very basic project, in unity there is just one script that opens the activity from android library on a button click.
I manually added the .aar in the /plugins/android folder (I am using 2019.4 version), and on build I keep getting the error that a resource is not found (Theme.AppCompat.Light.NoActionBar' not found in AndroidManifest)
.
This are my graddle config & AndroidManifest:
plugins {
id 'com.android.library'
}
android {
compileSdk 31
defaultConfig {
minSdk 21
targetSdk 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}
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 "com.facebook.react:react-native:+"
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
implementation 'com.google.android.material:material:1.4.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
//(MainApplication) Manual ReactPackage Setup here...
apply from: file("../../node_modules/#react-native-community/cli-platform-android/native_modules.gradle");
applyNativeModulesAppBuildGradle(project)
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name=".MainApplication"
android:allowBackup="true"
android:usesCleartextTraffic="true"
android:supportsRtl="true"
>
<activity android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
<activity
android:name=".ReactNativeActivity"
android:theme="#style/Theme.AppCompat.Light.NoActionBar"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize" />
</application>
</manifest>
I am a newbie when it comes to mobile development, but I think the issue is that the dependencies from build.graddle are not included in the .aar.
I think my options are to either create a fat .aar , manually download dependencies .aar's or to publish .aar to a central repository. Am I on the right track?
Any help is more than appriciated
I manage to get over the error by adding a custom graddle template to the unity project.

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 :)

Parse sdk "java.lang.NoSuchMethodError". Conflict between Okhttp Libraries

I am working with Parse SDK in android studio. Every thing was working fine untill i enabled multidex in my project because after adding the maps libraries my project exceeded 64K methods limit. I get following error when i run my app:
java.lang.NoSuchMethodError: com.squareup.okhttp.OkHttpClient.setFollowRedirects
at com.parse.ParseOkHttpClient.<init>(ParseOkHttpClient.java:58)
at com.parse.ParseHttpClient.createClient(ParseHttpClient.java:45)
at com.parse.ParsePlugins$Android.newHttpClient(ParsePlugins.java:175)
at com.parse.ParsePlugins.restClient(ParsePlugins.java:91)
at com.parse.Parse.getEventuallyQueue(Parse.java:615)
at com.parse.Parse.access$800(Parse.java:42)
at com.parse.Parse$1.call(Parse.java:410)
at com.parse.Parse$1.call(Parse.java:407)
at bolts.Task$4.run(Task.java:357)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at java.lang.Thread.run(Thread.java:856)
This is how my gradle file looks like:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
dexOptions {
javaMaxHeapSize "4g"
}
defaultConfig {
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.github.clans:fab:1.6.2'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.google.maps:google-maps-services:0.1.9'
compile 'com.google.maps.android:android-maps-utils:0.4'
compile 'com.balysv:material-ripple:1.0.2'
compile 'com.android.support:cardview-v7:23.3.0'
compile 'com.android.support:recyclerview-v7:23.3.0'
compile 'com.android.support:design:23.3.0'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:multidex:1.0.1'
compile('com.github.afollestad.material-dialogs:core:0.8.5.1#aar') {
transitive = true
}
compile 'com.parse.bolts:bolts-android:1.4.0'
compile 'com.parse:parse-android:1.13.0'
}
and this is my manifest file:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.rowburst.traverous.traverous">
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="23" />
<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" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:name="com.example.MyApplication"
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.geo.API_KEY"
android:value="#string/MAPS_API_KEY" />
<activity
android:name="com.example.LaunchingActivity"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoDisplay">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.LoginActivity"
android:theme="#style/Theme.AppCompat.Light.NoActionBar.FullScreen" />
<activity android:name="com.example.MainActivity"></activity>
</application>
And this is my application class:
public class MyApplication extends Application {
#Override
public void onCreate() {
super.onCreate();
Parse.initialize(new Parse.Configuration.Builder(this)
.applicationId(Const.APP_ID)
.server(Const.SERVER_URL)
.build());
}
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
I think the problem is in Parse.initialize statement in MyApplication class. Because when i debug my app and set a breakpoint on that statement (every thing seems fine before that statement) when the initialize statement is executed my app crashes. I have searched alot and i didnt find any solution to this problem. Please help...
EDIT:
Ok after further research and playing around with gradle dependencies i found out that this error is not because of multiDexEnabled rather it is because of conflict between okhttp library used by Parse and google-maps-services. Google-maps-services use OkHttp:2.0.0 where as Parse, i guess, uses OkHttp:2.4.0. I think OkHttp:2.0.0 has no such method of name setFollowRedirects and it is overriding OkHttp:2.4.0 thats why my app crashes. If i remove the google-maps-services compile statement my app works fine.
Note: If i do compile com.squareup.okhttp:okhttp:2.4.0 the error no more comes up but my parse functions (i.e. Login and Signup callback) give this error com.parse.ParseException:java.lang.IllegalArgumentException: value == null , they no longer work.
When you Initialize Parse pass empty string to client key.
Parse.initialize(new Parse.Configuration.Builder(this)
.applicationId(Const.APP_ID)
.server(Const.SERVER_URL)
.clientKey("")
.build());
Try adding
compile 'com.squareup.okhttp:okhttp:2.4.0'
to your build.gradle file.

error PARSING XML,UNBOUND PREFIX in manifest file

I have added a new dependency to my build.grade.after adding there is a error in my manifest.XML.the error is ERROR PARSING XML: UNBOUND PREFIX
Here is my manifest.XML
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ravakri.wm" >
<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>
<provider
android:authorities="com.ravakri.wm.notesprovider"
android:name=".NotesProvider"
android:exported="false"/>
</application>
</manifest>
Here is my build.grade
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.0"
defaultConfig {
applicationId "com.ravakri.wm"
minSdkVersion 15
targetSdkVersion 21
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.oguzdev:CircularFloatingActionMenu:1.0.2'
compile 'it.neokree:MaterialTabs:0.11'
}
Thanks in advance
manifest tag is not closed add
</manifest>
in the last line of your manifest file

Exception in plugin Android Support when running on device

I have just created a brand new android project with an single activity.
Manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.foo.bar">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme">
<activity
android:name="de.foo.bar.MainActivity"
android:label="#string/app_name"
android:launchMode="singleTop">
</activity>
</application>
</manifest>
Gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
defaultConfig {
applicationId "de.foo.bar"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.android.support:design:23.0.0'
}
When I just build the project no error appears. However when I try to run it on a device I get following error:
Exception in plugin Android Support:
null
java.lang.AssertionError
at org.jetbrains.android.run.DefaultActivityLocator.getQualifiedActivityName(DefaultActivityLocator.java:48)
at org.jetbrains.android.run.AndroidActivityLauncher.launch(AndroidActivityLauncher.java:95)
at org.jetbrains.android.run.AndroidRunningState.doPrepareAndStart(AndroidRunningState.java:855)
at org.jetbrains.android.run.AndroidRunningState.prepareAndStartApp(AndroidRunningState.java:810)
at org.jetbrains.android.run.AndroidRunningState.prepareAndStartAppWhenDeviceIsOnline(AndroidRunningState.java:771)
at org.jetbrains.android.run.AndroidRunningState.doStart(AndroidRunningState.java:603)
at org.jetbrains.android.run.AndroidRunningState.start(AndroidRunningState.java:579)
at org.jetbrains.android.run.AndroidRunningState$2.run(AndroidRunningState.java:310)
at com.intellij.openapi.application.impl.ApplicationImpl$8.run(ApplicationImpl.java:400)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:695)
at org.jetbrains.ide.PooledThreadExecutor$1$1.run(PooledThreadExecutor.java:56)
Any ideas what the problem is? I am using android studio 1.4.
I think it crashed because Android Studio can't locate the default / launcher activity, this occurs due to Android studio need to have defined a default activity, and you can do that adding intent-filter to your manifest.
Your activity entry at AndroidManifest should look like:
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme">
<activity
android:name="de.foo.bar.MainActivity"
android:label="#string/app_name"
android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
You can have activities without intent-filter, but you need at least one with this filter.
I had this same problem when I tried to generate the signed APK for my project, so the solution is to add this in you build.gradle file in your project:
android {
...
lintOptions {
checkReleaseBuilds false
abortOnError false
}
}

Categories

Resources