Can not add Biometric support API in my Old Android Project

旧巷老猫 提交于 2019-12-01 14:40:49

So finally after 14 days of struggle i made my 3 year old code working fine.

here are the detailed steps in case anyone is looking for same thing.

  1. So I had a Cordova android hybrid app old code . using Android studio 3.2 . Build gradle version was very old , 2.8 and gradle version was 3.3.

  2. I first of all upgraded Android studio to latest version 3.3.2

  3. Now i decided to migrate the whole project to androidX. Remember it wont even let me do that with the previous version of Android studio, i dont know why.

  4. When i clicked on Refactor -> Migrate to AndroidX. A pop up appeared saying "Upgrade the gradle version. So now I updated gradle version to 4.10.1 , it is still giving me error if i upgrade it to 5.2 ( i dont know why , I am still new to Android). Also updated build gradle to 3.3.2

5.My build.gradle (Module : App) looks like this :

apply plugin: 'com.android.application'

buildscript {
    repositories {
        jcenter{ url "http://jcenter.bintray.com/" }
        google()
    }

    // Switch the Android Gradle plugin version requirement depending on the
    // installed version of Gradle. This dependency is documented at
    // http://tools.android.com/tech-docs/new-build-system/version-compatibility
    // and https://issues.apache.org/jira/browse/CB-8143
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.2'
        classpath "com.google.gms:google-services:3.0.0" //FCM Config

    }
   }
  1. Now App is syncing fine , Build ok. I again tried Refactor -> Migrate to androidX. This time Android studio started refactoring the code and provided me 70 code change suggestions .

  2. These code changes are mainly the header file changes like : import "" . So I opened this link - https://developer.android.com/jetpack/androidx/migrate and changed every import statement to the equal androidx statment.

  3. After copy pasting all the changes I again compiled and synced the code . after 3 resources and code compilation error , I was able to build the code . This whole process took 1.2 hours .

  4. Finally i was able to import the biometric support API in build-extras.gradle (Module : app) , look at the file :

        dependencies {
            api 'androidx.appcompat:appcompat:1.0.2'
            api "com.squareup.picasso:picasso:2.4.0"
            api "com.google.android.material:material:1.1.0-alpha04"
            api "com.google.firebase:firebase-messaging:9.2.0" //FCM Config
            api 'com.rmtheis:tess-two:6.0.2'
            api 'com.github.bumptech.glide:glide:3.8.0'
            api 'androidx.legacy:legacy-support-v4:1.0.0'
    
            api "androidx.biometric:biometric:1.0.0-alpha03"
        }
    }
    
  5. Finally , I was able to build the complete code and sync it . So happy finally did it. Now i just have to use biometric API functions to integrate it into my code ( notice this code was written 3 years ago and given to me for integrating latest biometric API).

Yes I needed step by step answer like this one.

Still thanks to all who helped.

you need to define the repository in the root project's build.gradle:

allprojects {
    repositories {
        google()
    }
}

these versions are a) completely outdated and b) do not mix com.android.support with androidx. and you cannot add Java dependencies into the buildscript dependencies, because this produces the error message Could not find method implementation().

and maybe read the manual of this site, in order to provide input as a programmer would expect. only because you have a Mac does not exclude you from these guidelines ...which do exist for a reason.

DO NOT post images of code, data, error messages, etc. - copy or type the text into the question. Please reserve the use of images for diagrams or demonstrating rendering bugs, things that are impossible to describe accurately via text.

I could have simply fixed the dependencies, too... but I'm way too lazy to type from screenshots.

You are using implementation keyword which is not supported by your Gradle plugin (2.3.3)

You can definitely add it to your gradle you just need to use compile instead of implementation compile "androidx.biometric:biometric:1.0.0-alpha03"

If you want to use implementation you need to update your Gradle plugin. This would allow you to use newer android studio and but would require you to migrate some things to new gradle.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!