Cordova 打包 Android Q\&A 实操手册

229 阅读1分钟

编译模式 

image

 配置修改

以下只针对于老版本的项目

android / build.gradle

ext {
    agp_version = '3.5.1'
}

image

有的项目没有写 $agp_version 直接改成 3.5.1

shifleft() 方法报错 ,解决方案搜索本文件 "<<" 直接去掉

dependencies  类 下面 debugCompile , releaseCompile 直接改写法 ,复制下方写法

dependencies {
    implementation project(path: ':CordovaLib')
    compile fileTree(dir: 'libs', include: '*.jar')
    // SUB-PROJECT DEPENDENCIES START
    debugCompile(project(path: "CordovaLib"))
    releaseCompile(project(path: "CordovaLib"))
    compile "com.android.support:appcompat-v7:23+"
    compile "com.android.support:support-v4:24.1.1+"
    // SUB-PROJECT DEPENDENCIES END
}

android / project.properties

直接改为 28这个版本 ,防止版本过低无法通过编译

target=android-28

image

这里直接改成跟gradle形同的版本 ,防止编译重刷gradle之后配置全部失效

Cordova 构建过程报错修改

Q:

image

A: 根据提示建立多层路径

image

Q:

image

A:

image

Q:

image

A:

android / project.properties

以下为解法

Q:

image

A:

image

如上修改 gradlebuilder.js  gradle 版本信息

Q:

image

A:

dependencies  类 下面 debugCompile , releaseCompile 直接改写法 ,删掉后方调用的参数 参考本条地址

Q:

image

A:Android 版本号修改为28

Q: image

A: 

npm i xcode -g

npm i sermver -g

Q:

image

A:

找不到的 pulgin  到上层 aaa 的目录下 复制过来

Q:

support-compat-28.0.0/res/values/values.xml:57:5-88:25: AAPT: error: resource android:attr/fontStyle not found

A:

target = android-28

Q:

Could not find tools.jar. Please check that /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home contains a valid JDK installation.

A:

www.cnblogs.com/johnjackson… 解决方式 3

Q:

declares a dependency from configuration 'debugCompile' to configuration 'debug' which is not declared in the descriptor for project :CordovaLib.

A:

github.com/pwa-builder…