我想在我的应用中实现一个CollapsingToolbarLayout(我希望它像Play商店的视差效果)
我在stackOverflow本身以及Android的开发者网站上看到了很多问题。
问题是,我总是在IDE(Android Studio)中出现错误
The following classes could not be instantiated:
- android.support.design.widget.CollapsingToolbarLayout
如果我在手机上运行该活动,则该应用程序崩溃并显示错误
Caused by: java.lang.NoSuchMethodError: No static method setLayoutDirection(Landroid/graphics/drawable/Drawable;I)V in class Landroid/support/v4/graphics/drawable/DrawableCompat; or its super classes (declaration of 'android.support.v4.graphics.drawable.DrawableCompat' appears in /data/data/com.hemal.eventhub2/files/instant-run/dex/slice-com.android.support-support-v4-24.0.0_b8d850cc5f06d621d9211f2cbc20e32dfc36ae82-classes.dex)
at android.support.design.widget.CollapsingToolbarLayout.setStatusBarScrim(CollapsingToolbarLayout.java:663)
我很确定这与冲突的导入或依赖关系有关。
我的app模块gradle脚本是
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.hemal.eventhub2"
minSdkVersion 19
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'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.volley:volley:1.0.0'
compile 'com.android.support:design:23.2.1'
compile 'com.google.android.gms:play-services-auth:9.6.1'
compile 'com.google.firebase:firebase-core:9.6.1'
compile 'com.google.firebase:firebase-messaging:9.6.1'
}
apply plugin: 'com.google.gms.google-services'
以下是我应用的MainAcitivity中的一些导入
import android.support.design.widget.NavigationView;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.GravityCompat;
import android.support.v4.view.ViewPager;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
上述导入或依赖项是否存在冲突导致问题。 我还从1.5.1将我的Android Studio更新到2.2.1,希望它可以解决问题
您能否指导我删除,保存或下载哪些SDK,导入和依赖项以使CollapingToolbarLayout正常工作。