当前位置: 移动技术网 > 移动技术>移动开发>Android > Android Studio4如何在查看低版本API类的源代码?

Android Studio4如何在查看低版本API类的源代码?

2020年07月23日  | 移动技术网移动技术  | 我要评论

最近因为需要兼容旧版本的Android API,在编程时需要调用旧版本的类方法,但是因为build.gradle里面对应的编译版本是29,所以ctrl+点击函数,调到的源代码文件也是sdk29的文件,那么这里我们就可以直接修改编译版本,然后sync gradle,就可以查看的了,不过编译的时候你需要改回来的哦。

apply plugin: 'com.android.application'
android {
   // compileSdkVersion 29 //现在使用的版本
    compileSdkVersion 22 //查看旧代码时需要的版本

    defaultConfig {
        applicationId "com.xxxxx"
        minSdkVersion 22
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        
    }

    externalNativeBuild {
        ndkBuild {
            path file('jni/Android.mk')
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

}


dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'androidx.fragment:fragment:1.2.5'
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta8'
    testImplementation 'junit:junit:4.13'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

}

本文地址:https://blog.csdn.net/poolooloo/article/details/107400799

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网