我在使用较低的api时遇到问题,我在15、19和22 api上尝过了我的应用,开始时崩溃的唯一原因是在24或更高的api上,我不知道为什么我的应用只是数学计算。在过去的两天里很难找到答案,我尝试了无数种方法,但它们都不适合我。这是我完整的logcat错误和代码。感谢您的帮助。
E/memtrack: Couldn't load memtrack module (No such file or directory)
E/android.os.Debug: failed to load memtrack module: -2
E/memtrack: Couldn't load memtrack module (No such file or directory)
E/android.os.Debug: failed to load memtrack module: -2
? E/cutils-trace: Error opening trace file: Permission denied (13)
/? E/memtrack: Couldn't load memtrack module (No such file or directory)
? E/android.os.Debug: failed to load memtrack module: -2
? E/EGL_emulation: tid 1144: eglCreateSyncKHR(1865): error 0x3004
(EGL_BAD_ATTRIBUTE)
/? E/libprocessgroup: failed to make and chown /acct/uid_10058: Read-
only file system
? E/art: Failed writing handshake bytes (-1 of 14): Broken pipe
? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.slltour.desar.electricalcalculator, PID: 6967
android.content.res.Resources$NotFoundException: Resource ID #0x7f070066
at android.content.res.Resources.getValue(Resources.java:1266)
at android.support.v7.widget.AppCompatDrawableManager.loadDrawableFromDelegates(AppCompatDrawableManager.java:331)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:198)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:191)
at android.support.v7.content.res.AppCompatResources.getDrawable(AppCompatResources.java:102)
at android.support.v7.widget.AppCompatImageHelper.setImageResource(AppCompatImageHelper.java:86)
at android.support.v7.widget.AppCompatImageView.setImageResource(AppCompatImageView.java:94)
at android.widget.SimpleAdapter.setViewImage(SimpleAdapter.java:262)
at android.widget.SimpleAdapter.bindView(SimpleAdapter.java:192)
at android.widget.SimpleAdapter.createViewFromResource(SimpleAdapter.java:126)
at android.widget.SimpleAdapter.getView(SimpleAdapter.java:114)
at android.widget.AbsListView.obtainView(AbsListView.java:2347)
at android.widget.ListView.makeAndAddView(ListView.java:1864)
at android.widget.ListView.fillDown(ListView.java:698)
at android.widget.ListView.fillFromTop(ListView.java:759)
at android.widget.ListView.layoutChildren(ListView.java:1673)
at android.widget.AbsListView.onLayout(AbsListView.java:2151)
at android.view.View.layout(View.java:15671)
at android.view.ViewGroup.layout(ViewGroup.java:5038)
at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1076)
at android.view.View.layout(View.java:15671)
at android.view.ViewGroup.layout(ViewGroup.java:5038)
at android.support.v4.view.ViewPager.onLayout(ViewPager.java:1775)
at android.view.View.layout(View.java:15671)
at android.view.ViewGroup.layout(ViewGroup.java:5038)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1703)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1557)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1466)
at android.view.View.layout(View.java:15671)
at android.view.ViewGroup.layout(ViewGroup.java:5038)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579)
at android.widget.FrameLayout.onLayout(FrameLayout.java:514)
at android.view.View.layout(View.java:15671)
at android.view.ViewGroup.layout(ViewGroup.java:5038)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1703)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1557)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1466)
at android.view.View.layout(View.java:15671)
at android.view.ViewGroup.layout(ViewGroup.java:5038)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579)
at android.widget.FrameLayout.onLayout(FrameLayout.java:514)
at android.view.View.layout(View.java:15671)
at android.view.ViewGroup.layout(ViewGroup.java:5038)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1703)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1557)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1466)
at android.view.View.layout(View.java:15671)
at android.view.ViewGroup.layout(ViewGroup.java:5038)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579)
at android.widget.FrameLayout.onLayout(FrameLayout.java:514)
at android.view.View.layout(View.java:15671)
at android.view.ViewGroup.layout(ViewGroup.java:5038)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2086)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1843)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1061)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5885)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
at android.view.Choreographer.doCallbacks(Choreographer.java:580)
at android.view.Choreographer.doFrame(Choreographer.java:550)
at android.view.Choreographer$FrameDisplayE
// 这是我的主要代码
private int[] tabIcons = {
R.drawable.ic_home_tab,
R.drawable.ic_library_books_black_24dp,
R.drawable.calu_tab_icon,R.drawable.conv_tab_icon,
R.drawable.question_tab_icon};
ViewPager viewPager;
private TabLayout tabLayout;
private TabAdapter adapter;
Animation btnanim ;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
viewPager = findViewById(R.id.all_tabs);
tabLayout = findViewById(R.id.tabLayout);
adapter = new TabAdapter(getSupportFragmentManager());
adapter.addFragment(new tab1_fragment(), "Tb1");
adapter.addFragment(new tab2_fragment(), "Tb2");
adapter.addFragment(new tab3_fragment(), "Tb3");
adapter.addFragment(new tab4_fragment(), "Tb4");
adapter.addFragment(new tab5_fragment(), "Tb5");
btnanim = AnimationUtils.loadAnimation(this, R.anim.btnanim);
viewPager.setAdapter(adapter);
tabLayout.setupWithViewPager(viewPager);
setupTabIcons();
}
private void setupTabIcons() {
tabLayout.getTabAt(0).setIcon(tabIcons[0]);
tabLayout.getTabAt(1).setIcon(tabIcons[1]);
tabLayout.getTabAt(2).setIcon(tabIcons[2]);
tabLayout.getTabAt(3).setIcon(tabIcons[3]);
tabLayout.getTabAt(4).setIcon(tabIcons[4]);
}
}
build.gradle
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.slltour.desar.electricalcalculator"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:design:28.0.0'
implementation 'com.github.barteksc:android-pdf-viewer:2.8.2'
implementation 'org.jetbrains:annotations-java5:15.0'
implementation 'com.android.support:support-v4:28.0.0'
}
答案 0 :(得分:1)
更新 ,它是一块蛋糕;)3天后;(。
只需将您的PNG和图标移动到'Drawable'文件夹,而不是'Drawable-24'!