Reputation: 1264
I'm getting this error when building android application with Android studio :
24192-24192/com.mkapp.apps.demo1 W/dalvikvm﹕ VFY: unable to find class referenced in signature (Landroid/os/PersistableBundle;)
08-20 10:53:23.605 24192-24192/com.mkapp.apps.demo1 I/dalvikvm﹕ Could not find method android.support.v7.app.AppCompatActivity.onCreate, referenced from method com.mkapp.apps.demo1.TourActivity.onCreate
08-20 10:53:23.605 24192-24192/com.mkapp.apps.demo1 W/dalvikvm﹕ VFY: unable to resolve virtual method 8393: Landroid/support/v7/app/AppCompatActivity;.onCreate (Landroid/os/Bundle;Landroid/os/PersistableBundle;)V
08-20 10:53:23.605 24192-24192/com.mkapp.apps.demo1 D/dalvikvm﹕ VFY: replacing opcode 0x6f at 0x0000
my dependencies :
compile 'com.android.support:support-v4:22.2.1'
compile 'com.google.android.gms:play-services:7.3.0'
compile 'com.android.support:appcompat-v7:22.1.0+'
compile 'com.android.support:multidex:1.0.1'
many thanks for your help
old activities which inherit from AppcompatActivity work fine. but if I create new one ,it get the error . here is my gradle.build :
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
defaultConfig {
applicationId "com.mkapp.apps.demo1"
minSdkVersion 10
targetSdkVersion 22
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
multiDexEnabled true
}
dexOptions {
incremental true
javaMaxHeapSize "4g"
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile project(':photocollage')
compile project(':gWFacebookSDK')
// compile project(':listViewAnimation')
compile 'com.google.android.gms:play-services:7.3.0'
compile 'com.android.support:appcompat-v7:22.1.0'
compile 'com.android.support:multidex:1.0.1'
compile files('libs/aws-android-sdk-2.1.0-core.jar')
compile files('libs/aws-android-sdk-2.1.0-sns.jar')
compile files('libs/dexmaker-1.1.jar')
compile files('libs/dexmaker-mockito-1.1-custom.jar')
// compile files('libs/listviewanimations_lib-core_3.1.0.jar')
compile files('libs/signpost-commonshttp4-1.2.1.1.jar')
compile files('libs/signpost-core-1.2.1.1.jar')
compile files('libs/signpost-jetty6-1.2.1.1.jar')
compile files('libs/twitter4j-core-4.0.1.jar')
compile files('libs/universal-image-loader-1.9.3.jar')
}
Upvotes: 16
Views: 40635
Reputation: 569
1.Just change your dependencies to present in the build.gradle--
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:support-v4:23.4.0'
implementation 'com.android.support:appcompat-v7:23.4.0'
implementation 'com.android.support:support-annotations:27.1.1'
}
2.Then it will show to sync gradle, then sync build.gradle to update the changes.
Upvotes: 0
Reputation: 311
Simply , Goto the File-> Invalidate Caches and Restart. Thanks
Upvotes: 4
Reputation: 320
Here's a cheesy solution, but it actually worked for me ! I manually created the needed path to the missing library :
C:\Users\spomerleau\AppData\Local\Android\Sdk\extras\android\support\v7\appcompat\libs
and added the two missing .jar files from here and here. Android studio finally found the dependencies that needed to execute Java.
Upvotes: 0
Reputation: 25312
You need to Change your app build.gradle
like this:
compile 'com.android.support:appcompat-v7:22.1.0+'
to
compile 'com.android.support:appcompat-v7:20.0.0'
Upvotes: -1
Reputation: 32780
You have this issue because you are trying to use onCreate (Bundle savedInstanceState, PersistableBundle persistentState), but this method is available only from API level 21.
I am able to reproduce the issue with this sample code on Android 4.4:
public class TourActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState, new PersistableBundle());
}
@Override
public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
super.onCreate(savedInstanceState, persistentState);
}
}
And the issue is resolved removing every occurrence of PersistableBundle
:
public class TourActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
}
Check where you use PersistableBundle
in your TourActivity
and remove it or update your answer with the code of your activity.
Upvotes: 16
Reputation: 548
The problem is that your TourActivity
is using a class available only from API level 21 PersistableBundle. The question here is why is doing that.
Remember you new activity have to inherit from AppCompatActivity
as well.
Quick question, are you overriding public void onSaveInstanceState(Bundle outState, PersistableBundle outPersistentState)
in the problematic activity? If you are doing it you probably are saving a reference to PersistableBundle
which is not available in the device/emulator. Try removing it if you are not doing nothing there or comment it to try...
Upvotes: 5
Reputation: 38121
Update your support library to 23
and your compileSdkVersion
to 23
in build.gradle.
compileSdkVersion 23
...
compile 'com.android.support:support-v4:23.0.0'
compile 'com.android.support:appcompat-v7:23.0.0'
Then sync your project with gradle files.
Also, Google Play Services is now 7.8.0
Upvotes: 13
Reputation: 3062
First, update your libraries to the latest versions. Next, clean and rebuild your project.
Also, if this is a full list of libraries that you include:
compile 'com.android.support:support-v4:22.2.1'
compile 'com.google.android.gms:play-services:7.3.0'
compile 'com.android.support:appcompat-v7:22.1.0+'
compile 'com.android.support:multidex:1.0.1'
then you actually don't need to include this one
compile 'com.android.support:multidex:1.0.1'
Upvotes: 4