我在android studio中有一个项目正常工作,并且正如所期望的那样,API高于API 16(JellyBean及更高版本)的所有设备突然在向应用程序添加更多部分之后我只能在具有API的设备上运行它22安装在它上面(Lollipop),当我尝试在安装了Kitkat的设备上运行它时,我在启动器活动中得到以下致命异常:
Process: android.visitabudhabi.com.vad, PID: 2939
java.lang.VerifyError: android/support/v4/view/ViewPager
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at android.view.LayoutInflater.createView(LayoutInflater.java:594)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
at android.app.Activity.setContentView(Activity.java:2002)
at android.visitabudhabi.com.vad.Walkthrough.onCreate(Walkthrough.java:32)
at android.app.Activity.performCreate(Activity.java:5403)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2268)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2394)
at android.app.ActivityThread.access$800(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1293)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:149)
at android.app.ActivityThread.main(ActivityThread.java:5234)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
at dalvik.system.NativeStart.main(Native Method)
我的启动器类中的OnCreate方法(演练):
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_walkthrough);
ViewPager pager = (ViewPager) findViewById(R.id.pager);
adapter = new ScreenSlidePagerAdapter(getSupportFragmentManager());
pager.setAdapter(adapter);
MySQLiteHelper mySQLiteHelper=new MySQLiteHelper(this);
mySQLiteHelper.db_delete();
one= (ImageView) findViewById(R.id.first);
two= (ImageView) findViewById(R.id.second);
three= (ImageView) findViewById(R.id.third);
pager.setOffscreenPageLimit(3);
pager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
int pos;
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
pos=position;
if(position==0)
{
one.setBackgroundColor(Color.parseColor("#c7333f"));
}
else if(position==1)
{
two.setBackgroundColor(Color.parseColor("#c7333f"));
}
else if(position==2)
{
three.setBackgroundColor(Color.parseColor("#c7333f"));
}
}
@Override
public void onPageScrollStateChanged(int state) {
if (pos == 2 && state == 1) {
Intent intent=new Intent(Walkthrough.this,Settings.class);
startActivity(intent);
overridePendingTransition(R.anim.right_in, R.anim.left_out);
finish();
}
}
});
}
任何人都知道如何解决这个问题?
修改
这是我的build.gradle:
compile files('libs/pinit-sdk-1.0.jar')
compile project(':bounceScroller')
compile 'com.ogaclejapan.smarttablayout:library:1.2.1@aar'
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.github.navasmdc:MaterialDesign:1.5@aar'
compile 'com.nineoldandroids:library:2.4.+'
compile 'com.esri.arcgis.android:arcgis-android:10.2.6-2'
compile 'com.github.clans:fab:1.5.3'
compile 'com.github.pedrovgs:draggablepanel:1.8'
compile 'com.android.support:support-v4:22.2.0'
compile 'com.ogaclejapan.smarttablayout:utils-v4:1.2.1@aar'
compile 'com.github.bumptech.glide:glide:3.6.0'
compile project(':rangeseekbar')
compile 'com.android.support:recyclerview-v7:22.2.0'
compile 'com.android.support:cardview-v7:22.2.0'
compile project(':blurry')
compile 'com.google.android.gms:play-services:7.8.0'
这是我在布局中使用的ViewPager:
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:overScrollMode="never" />