0

today when I created a sample app "My Application" with all basic configuration like

compileSdkVersion 22
buildToolsVersion "26.0.1"
defaultConfig {
    applicationId "com.development.av.myapplication"
    minSdkVersion 21
    targetSdkVersion 22
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

with just one activity displaying hello world text.

even, my manifest file don't have any permission.

when I run this app on my testing device. its running well. which is having android version... 5.1.1

Then I send this app to my another android device which is having android version 6.0 but this device is not opening this app. installation was successful. but when I open this app, it gives me error saying, image1

when I click on try to resolve it gives another screen with option clear data ...after clicking on it it gives me another screen "app info" screen as...

image2

but I didn't understand what is the problem with my app? anyone please suggest...

my updated build configuration is as follows

compileSdkVersion 26
    buildToolsVersion "26.0.1"
    defaultConfig {
        applicationId "com.development.av.myapplication"
        minSdkVersion 21
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

but no luck !!!!

Here is my full source code of my app

build.gradle

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.1"
    defaultConfig {
        applicationId "com.development.av.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 {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:26.+'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
}

activity_main.xml

    <?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.development.av.myapplication.MainActivity">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</android.support.constraint.ConstraintLayout>

MainActivity.java

    package com.development.av.myapplication;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
}

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.development.av.myapplication">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>
av development
  • 53
  • 1
  • 10
  • Possible duplicate of [Unfortunately MyApp has stopped. How can I solve this?](https://stackoverflow.com/questions/23353173/unfortunately-myapp-has-stopped-how-can-i-solve-this) – OneCricketeer Sep 21 '17 at 06:10
  • can you at least post your logcat error ? – Benjamin Sep 21 '17 at 06:12
  • I am not getting any error in android studio. when I build apk fie of this project and send to the android 6.0 it was saying app stop working. it is working properly in my another device of android 5.1.1 – av development Sep 21 '17 at 06:14
  • Yes. Read the logs! That popup means nothing – OneCricketeer Sep 21 '17 at 06:14

2 Answers2

0

You need compileSdk 23 if you actually want to run on API 23 and earlier

And since you are using build tools 26, you might as well compile with 26

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
0

Target SDK Version Issue

To make your App run on Android 6 use:

targetSdkVersion 23 and compileSdkVersion 23

instead of

targetSdkVersion 22 and compileSdkVersion 22

It's Recommended to Use the code below to Support all Devices till Android Oreo

compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
    applicationId "com.development.av.myapplication"
    minSdkVersion 21
    targetSdkVersion 26
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
Akash
  • 687
  • 1
  • 4
  • 16
  • I upgrade my compile sdk version to 26 , now my build configuration is same as above but no luck.. my app not working on android 6.0 – av development Sep 21 '17 at 08:16
  • you can see my question ..I have posted my updated build configuration – av development Sep 21 '17 at 08:21
  • Can you share your complete Source Code; so that I can review the issue and try to help you better. – Akash Sep 21 '17 at 10:12
  • please check my updated question. I have posted full source code. – av development Sep 22 '17 at 03:58
  • hey, i notice something.. yesterday I was using my android 5.1.1 device for testing my project... so my project was working fine on that.. then I share that app using shareit to android 6.0 device. then it was showing error app stopped working. today I used my android 6.0 device for testing using usb debugging. and it is running my app successfully. then again I tried yesterdays procedure. but again my app not working on 6.0.... means when I use usb debugging its working. but when I share it from 5.1.1 device to 6.0 device its not working on 6.0.... why its happening??? – av development Sep 22 '17 at 04:27