我的应用程序在Lollipop设备上运行良好,但在版本Lollipop之前一直在崩溃。 我只是通过谷歌文档
在我的应用程序中使用以下代码实现了横幅添加 // Request for Ads
AdRequest adRequest = new AdRequest.Builder()
// Add a test device to show Test Ads
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.build();
// Load ads into Banner Ads
mAdView.loadAd(adRequest);
使用
compileSdkVersion 23
buildToolsVersion "23.0.1"
清单
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden
|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
错误
E/AndroidRuntime: FATAL EXCEPTION: main
E/AndroidRuntime: Process: com.app.aggro, PID: 13257
E/AndroidRuntime: java.lang.VerifyError:
com/google/android/gms/measurement/internal/zzv
E/AndroidRuntime: at
com.google.android.gms.measurement.AppMeasurementContentProvider
.onCreate(Unknown Source)
E/AndroidRuntime: at
android.content.ContentProvider.attachInfo(ContentProvider.java:1656)
E/AndroidRuntime: at
android.content.ContentProvider.attachInfo(ContentProvider.java:1627)
E/AndroidRuntime: at
android.app.ActivityThread.installProvider(ActivityThread.java:5015)
E/AndroidRuntime: at
android.app.ActivityThread.installContentProviders
(ActivityThread.java:4589)
E/AndroidRuntime: at
android.app.ActivityThread.handleBindApplication
(ActivityThread.java:4522)
E/AndroidRuntime: at
android.app.ActivityThread.access$1500(ActivityThread.java:151)
E/AndroidRuntime: at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1381)
E/AndroidRuntime: at
android.os.Handler.dispatchMessage(Handler.java:110)
E/AndroidRuntime: at android.os.Looper.loop(Looper.java:193)
E/AndroidRuntime: at
android.app.ActivityThread.main(ActivityThread.java:5299)
E/AndroidRuntime: at java.lang.reflect.Method.invokeNative(Native
Method)
E/AndroidRuntime: at
java.lang.reflect.Method.invoke(Method.java:515)
E/AndroidRuntime: at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
(ZygoteInit.java:825)
E/AndroidRuntime: at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:641)
E/AndroidRuntime: at dalvik.system.NativeStart.main
(Native Method)
我的Gradle文件是
apply plugin: 'com.android.application'
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
repositories {
mavenCentral()
maven { url
"https://oss.sonatype.org/content/repositories/snapshots"}
maven { url 'https://maven.fabric.io/public' }
maven { url
"https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url 'https://dl.bintray.com/drummer-aidan/maven' }
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.app.aggro"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-
android.txt'), 'proguard-rules.pro'
}
}
dexOptions{
incremental true
javaMaxHeapSize "4g"
}
defaultConfig {
multiDexEnabled true
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.1'
compile('com.mikepenz:materialdrawer:3.0.9@aar') {
transitive = true
}
compile('com.github.florent37:materialviewpager:1.1.0@aar') {
transitive = true
}
compile('com.crashlytics.sdk.android:crashlytics:2.4.0@aar') {
transitive = true;
}
compile 'com.google.android.gms:play-services:8.1.0'
compile 'com.mcxiaoke.volley:library:1.0.+'
compile 'com.google.code.gson:gson:2.3.1'
compile 'com.marshalchen.ultimaterecyclerview:library:0.3.11'
compile 'com.android.support:recyclerview-v7:22.2.0'
compile 'com.android.support:cardview-v7:23.0.1'
compile 'com.jpardogo.googleprogressbar:library:1.2.0'
compile 'com.quinny898.library.persistentsearch:library:1.0.0-
SNAPSHOT'
compile project(':storage')
compile 'com.getbase:floatingactionbutton:1.10.0'
compile 'com.parse.bolts:bolts-android:1.+'
compile files('libs/activeandroid-3.1-beta.jar')
compile 'com.android.support:design:23.0.1'
compile 'it.neokree:MaterialTabs:0.11'
compile 'com.miguelcatalan:materialsearchview:1.2.0'
}
请帮我解决这个问题。
答案 0 :(得分:34)
在问题上扩展了一个多小时后,我发现我必须在MyApplication
类中进行一些修改,如下所示:
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
// register with Active Android
ActiveAndroid.initialize(this);
}
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
我已经覆盖了attachbaseContext
方法,现在一切正常。
答案 1 :(得分:5)
+)使用超过65K的方法构建应用程序将导致此错误。
+)当您的应用程序及其引用的库达到一定大小时(应用程序的 DEX文件可以包含方法的总数达到65,536 ,包括Android框架方法,库方法和您自己的代码中的方法),您遇到的构建错误表明您的应用已达到Android应用构建体系结构的限制。
+)要解决此问题,请在 build.gradle 中添加 Multidex配置,例如图片中突出显示的内容,以及此覆盖您的Application类中的 attachBaseContext(Context base)方法,其中包含以下内容。
public class YourParentApplication extends Application {
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
在你的Androidmanifest.xml中添加:
<application
android:name=".YourParentApplication"
android:allowBackup="true"
android:icon="@drawable/radiius_logo"
android:label="@string/app_name"
android:largeHeap="true"
android:theme="@style/MyMaterialTheme">
有关Multidex的更多信息,请参阅以下网站: http://developer.android.com/tools/building/multidex.html
How to enable multidexing with the new Android Multidex support library
答案 2 :(得分:0)
您应该降低AndroidManifest.xml中的API 棒棒糖是API 21。
检查一下:API Levels 例如:
defaultConfig {
applicationId "com.package.name"
minSdkVersion 11
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
答案 3 :(得分:0)
将你的minSdkversion减少到你想要支持的那个版本
在项目的gradle文件中
如下所示
minSdkVersion 10