-
Notifications
You must be signed in to change notification settings - Fork 1
/
notepad.txt
250 lines (214 loc) · 16.3 KB
/
notepad.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
应用图标位于res/icon.png
启动页面位于res/splash.png
如需要编译其他的软件,请自行cordova clean清除编译文件后再打包
如果AndroidManifest.xml没有:
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:maxSdkVersion="32" android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:maxSdkVersion="32" android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
则请在项目根目录执行三遍cordova build android,而不是直接在config.xml添加。补全的代码在hooks文件夹里
#tip:忽略这条,导致上面的原因是因为cordova-plugin-camera插件太新了,降级到4.0.3即可
如果有如下错误:
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AppCompatActivity;
可以改为:
import androidx.core.app.ActivityCompat;
import androidx.appcompat.app.AppCompatActivity;
————————————————
原文链接:https://blog.csdn.net/hzhnzmyz/article/details/109570216
如果您遇上了:Source directory does not exist: /workspaces/CoCo_Cordova/node_modules/cordova-android/bin/templates/platform_www
那么您需要先cordova platform rm android
然后再cordova platform add android(自行制定您想安装的版本).
这么做是为了刷新项目
如果您遇上了:Unable to make field private final java.lang.String java.io.File.path accessible: module java.base does not "opens java.io" to unnamed module @5646e38c
请将您系统的java环境更改为1.8
如果您使用了自动脚本,codespace下只要执行:sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/java-8-openjdk-amd64/bin/java 1511 ;sudo update-alternatives --install /home/codespace/java/current/bin/java java /usr/lib/jvm/java-8-openjdk-amd64/bin/java 1511 ;sudo update-alternatives --config java && sudo update-alternatives --config javac
然后选择/usr/lib/jvm/java-8-openjdk-amd64/bin/java和/usr/lib/jvm/java-8-openjdk-amd64/bin/javac,不是/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java !
如果您遇上了:No matching variant of com.android.tools.build:gradle:8.3.0 was found. The consumer was configured to find a library for use during runtime, compatible with Java 8, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '8.7'
请将您系统的java环境更改为17(一般情况下java11都行,但是本人只有在17下进行过测试和开发)
造成这个原因主要是android sdk的build tools自从34.0.0就开始强制使用jdk11以上了
如果您使用了自动脚本,codespace下只要执行:sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/java-17-openjdk-amd64/bin/java 1511 && sudo update-alternatives --install /home/codespace/java/current/bin/java java /usr/lib/jvm/java-17-openjdk-amd64/bin/java 1511 ;sudo update-alternatives --config java && sudo update-alternatives --config javac;
然后选择'/usr/lib/jvm/java-17-openjdk-amd64/bin/java' 即可
cordova-plugin-stepper插件必须是@felicienfrancois\cordova-plugin-stepper
coco辨别web与android的方法是检测UserAgent字符串是否有Cordova
随着Android studio版本的升级,会出现无法引用android.support.v4包
解决办法:
将
android:name="android.support.v4.content.FileProvider"
修改为
android:name="androidx.core.content.FileProvider"
即可
————————————————
原文链接:https://blog.csdn.net/qq_31877171/article/details/114266592
General error during semantic analysis: Unsupported class file major version 61:更改您的Java版本到8,怎么改install-JDK-Android_SDK.sh有说:
如果您使用了自动脚本,codespace下只要执行:sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/java-8-openjdk-amd64/bin/java 1511 ;sudo update-alternatives --install /home/codespace/java/current/bin/java java /usr/lib/jvm/java-8-openjdk-amd64/bin/java 1511 ;sudo update-alternatives --config java && sudo update-alternatives --config javac
然后选择/usr/lib/jvm/java-8-openjdk-amd64/bin/java和/usr/lib/jvm/java-8-openjdk-amd64/bin/javac,不是/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java !
cordova 9.0 构建时提示Requirements check failed for JDK 8 如何解决:https://blog.csdn.net/sunwe/article/details/106295073
因为cordova基于的nodejs,突然想到,所有的提示都应该存在于明文代码。于是一狠心,全项目搜索关键字Requirements check failed for。
还真就检索到了:
位于platforms/android/cordova/lib/check_reqs.js (node_modules/cordova-android/bin/templates/cordova/lib/check_reqs.js) 文件里的module.exports.run方法里,相关的有且仅有一处!
// Returns a promise.
module.exports.run = function () {
return Q.all([this.check_java(), this.check_android()]).then(function (values) {
console.log('Checking Java JDK and Android SDK versions');
console.log('ANDROID_SDK_ROOT=' + process.env['ANDROID_SDK_ROOT'] + ' (recommended setting)');
console.log('ANDROID_HOME=' + process.env['ANDROID_HOME'] + ' (DEPRECATED)');
if (!String(values[0]).startsWith('1.8.')) {
throw new CordovaError(
'Requirements check failed for JDK 8 (\'1.8.*\')! Detected version: ' + values[0] + '\n' +
'Check your ANDROID_SDK_ROOT / JAVA_HOME / PATH environment variables.'
);
}
if (!values[1]) {
throw new CordovaError('Requirements check failed for Android SDK! Android SDK was not detected.');
}
});
(实际上这个地方已经改了,修改成变量了,这个变量位置在开头且是:const EXPECTED_JAVA_VERSION = '1.8.x';)
(如果您遇到了这个问题,直接到项目根目录下的hooks目录的install_android9.js中将java版本变量设置成您自己的即可,在您编译的时候脚本会自己修改)
看到了这个1.8的判断条件,同时根据check_java方法也可以明确为判断java环境。于是把“1.8.”直接改成了“11.”,再次编译顺利通过。
后记:
首先我是不推荐任意更改依赖框架源码的,这样不但会影响框架后续更新,也会造成一些未知异常。但没办法,此处仅作为临时解决方案。
我不清楚cordova9是否有只依赖jdk8的关键部分,我也不清楚jdk11会对cordova9造成什么影响,但是我想的很清楚,不管如何要让影响降低到最小,改一处代码,这个影响就真的很小。
如果遇上class版本错误,看看这个↓
Has been compiled by a more recent version of the Java Runtime (class file version 57.0):https://stackoverflow.com/questions/58125830/has-been-compiled-by-a-more-recent-version-of-the-java-runtime-class-file-versi
如果遇上android-sdk路径问题,看看这个↓
Android Command line tools sdkmanager always shows: Warning: Could not create settings:https://stackoverflow.com/questions/60440509/android-command-line-tools-sdkmanager-always-shows-warning-could-not-create-se/61176718#61176718
想自己手动安装Android-SDK?看看这个↓
Installing Android SDK Tools:https://guides.codepath.com/android/installing-android-sdk-tools
ubuntu切换JDK版本:https://blog.csdn.net/qq_42824983/article/details/114674833
sudo update-alternatives --config java
android-27=android-8.0
android-28=android-9.0
android-29=android-10.0
android-30=android-11.0
android-31=android-12.0
android-32=android-12.0
android-33=android-13.0
android-34=android-14.0
android-35=android-15.0
Ubuntu 安装java jdk 16:https://blog.csdn.net/phker/article/details/121849172
sudo add-apt-repository ppa:openjdk-r/ppa
sudo apt-get update
sudo apt-get install openjdk-16-jdk
sudo su
export JAVA_HOME=/usr/lib/jvm/java-16-openjdk-amd64>>/etc/profile
// 重新加载一下环境变量
source /etc/profile
————————————————
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/phker/article/details/121849172
I am also facing same issue.
Replace Whitelist class with AllowList in cordova-plugin-file-transfer > src > android > FileTransfer.java
import org.apache.cordova.Whitelist; => import org.apache.cordova.AllowList;
https://github.com/apache/cordova-plugin-file-transfer/issues/306
#已弃用,已将cordova-plugin-whitelist卸载。如果需要请自己重装修复
#20240916,由于CP需要,已重新安装该插件。
https://github.com/apache/cordova-android/issues/1604
./gradlew --stacktrace cdvBuildDebug -b build.gradle
You may not have your ANDROID_HOME variable set. Cordova makes educated guesses and it's possible Cordova is guessing correctly but would be better to explicitly set your ANDROID_HOME however in your .bashrc file. You'll need to start a new terminal session for changes to apply.
export ANDROID_HOME="/path/to/android/sdk"
General error during conversion: Unsupported class file major version 61
Means you're using Java 17 (which is file major version 61) . AGP 7.x, which is what cordova-android@11 uses requires Java 11.
Would be best to use Java 11 for Cordova. CORDOVA_JAVA_HOME can be used to tell cordova where a JDK 11 installation is, while having JDK 17 for other things.
As mentioned #1604 one of the breaking changes of AGP 8 requiring JDK 17, so support for JDK 17 will be coming soon, but I'm not sure if it will be included in our next release since AGP 8 is only necessary for API 34, which will be in beta until summer of this year at the earliest.
https://stackoverflow.com/questions/75114728/no-matching-variant-of-com-android-tools-buildgradle7-4-0-was-found
There are two ways to change Gradle JDK to 11.
File -> Settings -> Build, Execution, Deployment -> Build Tools -> Gradle
or config in gradle.properties:
"org.gradle.java.home= /xxx/Java/jdk-11.0.1"
Note that the compile, runtime, testCompile, and testRuntime configurations introduced by the Java plugin have been deprecated since Gradle 4.10 (Aug 27, 2018), and were finally removed in Gradle 7.0 (Apr 9, 2021).
The aforementioned configurations should be replaced by implementation, runtimeOnly, testImplementation, and testRuntimeOnly, respectively.
如果你遇到了执行"pod setup"后cordova依旧无法使用的话
可以先卸载掉cocoapods然后安装[email protected]
之后再执行"pod setup",这将会让它从github下载依赖下载
大约会占用2G左右,流量1G.安装前确保您有足够空间和流量(你知道我指的是哪个流量的(嗯)).
安装完成后,就可以卸载掉[email protected]
然后再安装最新版本,安装完成后再执行"pod setup"后一般就能用了.
如果你遇上了"Command failed with exit code 1: pod --version"
那么你可以试试:gem install ffi cocoapods && sudo gem install ffi cocoapods
如果你是arm电脑,试试:arch -x86_64 gem install ffi cocoapods && sudo arch -x86_64 gem install ffi cocoapods
关于"pod install --verbose"报错这件事[
'如果你遇上报错信息包含:(mach-o file, but is an incompatible architecture (have (arm64), need (x86_64h)))
那么你可以在项目根目录里试试:sudo gem uninstall ffi&& sudo gem install ffi
如果你是arm电脑,试试:sudo gem uninstall ffi && sudo arch -x86_64 gem install ffi
这两条指令可能会帮助到您,如果不能,试试提issue或者联系我试试能不能解决(本人mac设备是2015年的mac air)
',
'如果遇到了报错信息包含:Could not find 'ffi' (>= 1.15.0) among 96 total gem(s) (Gem::MissingSpecError)
那么你可以试试:sudo gem install ffi
如果你是arm电脑,试试:sudo arch -x86_64 gem install ffi
',
'如果你遇上了报错信息包含:REXML::ParseException - #<TypeError: wrong argument type String (expected Regexp)>
可以查看这些网址:
https://github.com/CocoaPods/CocoaPods/issues/12433
https://github.com/CocoaPods/CocoaPods/issues/12392#issuecomment-2178749668
https://www.moncefbelyamani.com/how-to-install-xcode-homebrew-git-rvm-ruby-on-mac/
大概地情况就是,这个问题会发生在你用的是系统自带的ruby或你在用arm电脑上
你可以通过这些网址学会怎么正确安装ruby
简单来讲,命令就是这些.输入完成后如果安装成功了重启终端即可:
brew install chruby ruby-install
ruby-install ruby
echo "source $(brew --prefix)/opt/chruby/share/chruby/chruby.sh" >> ~/.zshrc
echo "source $(brew --prefix)/opt/chruby/share/chruby/auto.sh" >> ~/.zshrc
echo "chruby ruby-3.3.4" >> ~/.zshrc
']
如果你在xcode调试的时候遇到了:'SocketRocket/SocketRocket.h' file not found
在项目根目录的platforms/ios中执行下"pod install"即可
如果还是不行
那么你一定打开的是.xcodeproj而不是.xcworkspace
打开.xcworkspace文件才是
ios项目还额外安装了ios-sim、ios-deploy和cordova-plugin-console
ios-sim可以通过"sudo npm install -g ios-sim"安装
cordova-plugin-console可以通过"cordova plugin add cordova-plugin-console"
ios-deploy请通过"npm install -g ios-deploy"安装
而针对CreationProject项目,
我们还额外安装了cordova-plugin-whitelist、cordova-plugin-badge、cordova-plugin-local-notification和cordova-plugin-x-socialsharing
由于cordova-plugin-x-socialsharing的原因,在cordova-android@9下你可能还需要安装cordova-plugin-androidx以使用androidx库.
但我强烈不推荐cordova-android@9下使用任何的androidx库,这样会导致hook的脚本以及绝大部分插件都会出问题!
如果您用不到这些插件,在cordova删除它们的同时。还请您检查下hook文件夹的脚本是否有用到它们并注释它们。以防出现无法意料的情况。
通常针对不同平台的时候,在脚本的主函数中会有一个开关变量,使用布尔值即可开关功能。
关于config.xml/plugin.xml修改AndroidManifest注意:
如果你在plugin.xml或config.xml使用了 config-file或edit-config等类似参数
若要删除它们的话,在config.xml/plugin.xml删除了的同时,
还需到platforms\android\android.json和platforms\android\app\src\main\AndroidManifest.xml删除它们
否则所做的更改仍然保留
如果您遇到了Attempt to invoke virtual method 'android.content.res.XmlResourceParser。。。。这样的错误,
看看这两个:https://blog.csdn.net/qq_33721320/article/details/106012082 和 https://github.com/apache/cordova-plugin-camera/issues/486
关于修改插件的内容:
不仅仅需要更改plugins里的插件,还需要更改node_modules和platforms文件夹里的插件
目前已知bug:[‘4.e8bfe7ab.chunk.js:2 Uncaught TypeError: Cannot read property 'clientX' of undefined’]
由于android 10起不再支持全局启动页面,且cordova android 12自带splash。
因此cordova-plugin-splashscreen已被弃用,但仍然会被安装.
如果您需要这类的启动图,请自行降低cordova-android并对相关插件和配置进行修改
https://stackoverflow.com/questions/73720590/is-there-a-way-to-still-have-full-screen-splash-images-in-cordova-android-11
附带2024/04/21截止,CoCo_Cordova插件版本:
#出于兼容问题,本模板部分模块经过修复和版本升级
#可能与一下模块版本不同,仅作参考使用
module.exports.metadata = {
"cordova-plugin-whitelist": "1.3.4",
"cordova-plugin-geolocation": "4.1.0",
"es6-promise-plugin": "4.2.2",
"cordova-plugin-screen-orientation": "3.0.2",
"cordova-plugin-magnetometer": "1.0.0",
"cordova-plugin-device-motion": "2.0.1",
"cordova-plugin-shake": "0.7.0",
"cordova-plugin-android-permissions": "1.1.2",
"cordova-plugin-device": "2.0.3",
"cordova-plugin-file": "6.0.2",
"cordova-plugin-media": "5.0.3",
"cordova-plugin-camera": "4.0.3",
"cordova-plugin-media-capture": "3.0.3",
"cordova-plugin-viewport": "1.0.5",
"cordova-plugin-advanced-http": "3.1.1",
"cordova-plugin-vibration": "2.1.6",
"cordova-plugin-phone-call": "1.1.3",
"cordova-plugin-calltrap": "0.0.4",
"cordova-sms-plugin": "1.0.1",
"cordova-plugin-contacts": "3.0.1",
"cordova-plugin-sms-receive": "1.0.2",
"cordova-plugin-x-toast": "2.7.2",
"cordova-plugin-advanced-websocket": "1.1.6",
"cordova-plugin-battery-status": "2.0.3",
"cordova-plugin-brightness": "0.1.5",
"@felicienfrancois/cordova-plugin-stepper": "0.2.53",
"@crc/cordova-plugin-qrscanner": "3.2.0",
"cordova-plugin-splashscreen": "6.0.2"
};