ถ้ามีภาพในเครื่อง น่าจะแสดงภาพออกมา
build.gradle (Project: MyApplication)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.1.4' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { google() jcenter() maven { url 'https://jitpack.io' } } } task clean(type: Delete) { delete rootProject.buildDir } |
build.gradle (Module: app)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
apply plugin: 'com.android.application' android { compileSdkVersion 26 defaultConfig { applicationId "com.phaisarn.myapplication" minSdkVersion 21 targetSdkVersion 26 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']) implementation 'com.android.support:appcompat-v7:26.1.0' implementation 'com.android.support.constraint:constraint-layout:1.1.3' implementation 'com.android.support:design:26.1.0' 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.github.vansikrishna:Multimager:1.0.6' } |
เปิดขึ้นมา พอกดปุ่ม แอพดับหายไปเลย ปัญหาน่าจะเป็นเรื่องของ version ของไลบรารีอีกเหมือนเดิม
[code]
09-21 15:53:50.275 1674-26726/? E/NativeCrashListener: Unable to report native crash
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.get(ArrayList.java:437)
at com.android.server.am.ActivityStack.finishTopRunningActivityLocked(ActivityStack.java:3510)
at com.android.server.am.ActivityStackSupervisor.finishTopRunningActivityLocked(ActivityStackSupervisor.java:2091)
at com.android.server.am.AppErrors.handleAppCrashLocked(AppErrors.java:643)
at com.android.server.am.AppErrors.makeAppCrashingLocked(AppErrors.java:501)
at com.android.server.am.AppErrors.crashApplicationInner(AppErrors.java:376)
at com.android.server.am.AppErrors.crashApplication(AppErrors.java:321)
at com.android.server.am.ActivityManagerService.handleApplicationCrashInner(ActivityManagerService.java:14253)
at com.android.server.am.NativeCrashListener$NativeCrashReporter.run(NativeCrashListener.java:85)
[/code]
เลยเปลี่ยนค่าใหม่เป็นตามนี้ ใช้ได้เลย
build.gradle (Module: app)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
apply plugin: 'com.android.application' android { compileSdkVersion 25 defaultConfig { applicationId "com.phaisarn.myapplication" minSdkVersion 21 targetSdkVersion 25 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']) implementation 'com.android.support:appcompat-v7:25.4.0' implementation 'com.android.support.constraint:constraint-layout:1.1.3' implementation 'com.android.support:design:25.4.0' 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.github.vansikrishna:Multimager:1.0.6' } |
content_main.xml
MainActivity.java