lundi 22 avril 2019

Android Studio 3.4 - Unable to debug onClickListeners

I have recently updated the android studio. After updating I started getting problems with testing the app using USB device. I was getting app installation failed error randomly.

Now unable to debug at all.

My android stdio version is 3.4

Manifest file

 <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:dist="http://schemas.android.com/apk/distribution"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.CrediPay">

    <dist:module dist:instant="true" />

    <uses-feature
        android:name="android.hardware.camera.autofocus"
        android:required="false" />

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.VIBRATE" />

    <application
        android:name="com.CrediPay.Application.MyApplication"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher_round"
        android:label="@string/app_name"
        android:debuggable="true"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme"
        android:hardwareAccelerated="true"
        android:usesCleartextTraffic="true"
        tools:ignore="HardcodedDebugMode">
        <activity
            android:name="com.CrediPay.Activities.RegisterActivity"
            android:label="@string/app_name"
            android:theme="@style/AppTheme.NoActionBar"
            android:windowSoftInputMode="stateAlwaysHidden">

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

        </activity> 

        <receiver
            android:name="com.CrediPay.Helper.MySMSBroadcastReceiver"
            android:exported="true"
            android:permission="android.permission.BROADCAST_SMS">
            <intent-filter android:priority="5822">
                <action android:name="android.provider.Telephony.SMS_RECEIVED" />
            </intent-filter>
        </receiver>
    </application>

</manifest>

App Gradle

  apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.CrediPay"
        minSdkVersion 16
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            multiDexEnabled = true
            debuggable = true
            jniDebuggable = true
            renderscriptDebuggable = true
        }
        debug {
            minifyEnabled = true
            multiDexEnabled = true
        }
    }
    buildToolsVersion '29.0.0 rc1'

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'androidx.appcompat:appcompat:1.1.0-alpha04'
    implementation 'com.google.android.gms:play-services-auth-api-phone:16.0.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha4'
    implementation 'com.google.android.material:material:1.1.0-alpha05'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation('com.github.bumptech.glide:glide:4.9.0') { exclude group: "com.android.support" }
    annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
    implementation 'androidx.multidex:multidex:2.0.1'
    implementation 'com.google.guava:guava:27.0.1-android'
    // material ripple, morphing button, material dialog, animations
    implementation 'com.balysv:material-ripple:1.0.2'
    implementation('com.github.afollestad.material-dialogs:core:0.8.5.1@aar') {
        transitive = true
    }
    implementation 'com.google.guava:guava:27.0.1-android'
    implementation 'com.airbnb.android:lottie:3.0.0'
    implementation 'com.squareup.picasso:picasso:2.71828'
    testImplementation 'junit:junit:4.13-beta-2'
    androidTestImplementation 'androidx.test:runner:1.2.0-alpha04'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0-alpha04'
    implementation 'androidx.cardview:cardview:1.0.0'
}

build gradle

buildscript {
    repositories {
        google()
        jcenter()
        maven { url "https://jitpack.io" }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.0'

        // 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
}

Not sure which code to add. I tried to restart adb by using

command adb kill-server

it shows error 'adb' 'adb' is not recognized as an internal or external command, operable program or batch file.

Please suggest solution. Thank you.

Aucun commentaire:

Enregistrer un commentaire