關於多渠道打包依賴不同sdk的方式

最近公司做的應用需要適配不同的項目,但是我們每一個項目都有一個寫用戶中心的同事,這就需要我的應用要適配所有項目中不同同事寫的用戶中心sdk。這樣只能用到flavors來完成了。

以下是demo下的代碼 不能透漏公司的代碼嘛畢竟

 flavorDimensions "program"
    productFlavors{
        mytest {
            dimension "program"
            buildConfigField("String","name","\"test1\"")
        }
        youtest {
            dimension "program"
            buildConfigField("String","name","\"test2\"")
        }
    }


    repositories {
        flatDir{
            dirs 'libs'
        }
    }
    sourceSets{
        main{
            jniLibs.srcDirs = ['libs']
        }
        mytest {
            java {
                srcDirs 'src\\mytest\\java'
            }

//            res{
//                srcDirs 'src\\mytest\\res'
//            }
        }
        youtest {
            java {
                srcDirs 'src\\youtest\\java'
            }
        }

    }

dependencies {
//    implementation fileTree(dir: "libs", include: ['*.jar', '*.aar'])
    implementation 'androidx.appcompat:appcompat:1.3.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
    //noinspection GradleCompatible
    implementation 'com.android.support:recyclerview-v7:27.1.1'
    mytestImplementation files('libs/libaccount-c490-0.7.jar') //這裏就是使用mytest項目打包的時候使用到的sdk
    youtestImplementation(name:'libaccount-wt30r-20210412',ext:'aar') //這裏就是使用youtest項目打包的時候使用到的sdk


}


在工程裏 大概是這個樣子滴

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章