当前位置:   article > 正文

AndroidStudio编译期间修改applicationId_android studio applicationid

android studio applicationid
  1. 1.打开这个文件“项目文件夹\app\build.gradle”,在文件的第二行加入以下代码:
  2. import org.json.JSONObject
  3. String currentDir = "${project.rootProject.projectDir}"
  4. File jsonFile = new File(currentDir + "/app/src/main/assets/a.json")
  5. FileInputStream fileInputStream = new FileInputStream(jsonFile)
  6. InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream)
  7. BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(jsonFile)))
  8. String content = ""
  9. String temp
  10. while ((temp = bufferedReader.readLine()) != null) {
  11. content += temp
  12. }
  13. fileInputStream.close()
  14. inputStreamReader.close()
  15. bufferedReader.close()
  16. JSONObject jsonObject = new JSONObject(content)
  17. String newPackageName = jsonObject.getString("applicationId ")
  18. android.defaultConfig.applicationId = newPackageName
  19. 2.把applicationId 'com.cc.com'这一行删掉。(修改结束)

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小蓝xlanll/article/detail/486819
推荐阅读
相关标签
  

闽ICP备14008679号