我仍然使用一个较旧的插件,该插件可以安装并在cordova-android@6.x上正常工作,但是不能安装或与cordova-android@7.x(+)一起工作。
这是一个路径对齐问题...将v6中有效的安装路径转换为v7所需的新路径。
我分叉了该插件,并尝试更新所有路径,以便可以在cordova-android@7.x及更高版本中正确安装。我知道它可以很好地安装,但是当应用程序在设备/电话上编译并启动时-应用程序在使用“未找到类”启动时出错。
应用启动时出现实际错误:
Alert: Error initializing Cordova: class not found
Application Error: The connection to the server was unsuccessful (file:///android_asset/www/index.html)
原始文件:
<platform name="android">
<config-file target="res/xml/config.xml" parent="/*">
<feature name="DialogGPS">
<param name="android-package" value="cl.rmd.cordova.dialoggps.DialogGPS"/>
</feature>
</config-file>
<source-file src="src/android/DialogGPS.java" target-dir="src/cl/rmd/cordova/dialoggps" />
<source-file src="www/icon/drawable-hdpi/ic_location.png" target-dir="res/drawable-hdpi/"/>
<source-file src="www/icon/drawable-mdpi/ic_location.png" target-dir="res/drawable-mdpi/"/>
<source-file src="www/icon/drawable-xhdpi/ic_location.png" target-dir="res/drawable-xhdpi/"/>
<source-file src="www/icon/drawable-xxhdpi/ic_location.png" target-dir="res/drawable-xxhdpi/"/>
<source-file src="www/icon/drawable-xxxhdpi/ic_location.png" target-dir="res/drawable-xxxhdpi/"/>
<config-file target="AndroidManifest.xml" parent="/manifest">
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
</config-file>
</platform>
更改为:
<platform name="android">
<config-file target="/app/src/main/config.xml" parent="/*"> <!-- target path updated -->
<feature name="DialogGPS">
<param name="android-package" value="cl.rmd.cordova.dialoggps.DialogGPS"/>
</feature>
</config-file>
<source-file src="src/android/DialogGPS.java" target-dir="src/cl/rmd/cordova/dialoggps" /> <!-- I think this is the issue -->
<source-file src="www/icon/drawable-hdpi/ic_location.png" target-dir="/app/src/main/res/drawable-hdpi/"/> <!-- target paths updated -->
<source-file src="www/icon/drawable-mdpi/ic_location.png" target-dir="/app/src/main/res/drawable-mdpi/"/>
<source-file src="www/icon/drawable-xhdpi/ic_location.png" target-dir="/app/src/main/res/drawable-xhdpi/"/>
<source-file src="www/icon/drawable-xxhdpi/ic_location.png" target-dir="/app/src/main/res/drawable-xxhdpi/"/>
<source-file src="www/icon/drawable-xxxhdpi/ic_location.png" target-dir="/app/src/main/res/drawable-xxxhdpi/"/>
<config-file target="AndroidManifest.xml" parent="/manifest">
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
</config-file>
</platform>
我认为问题出在java文件的目标路径,但我也不知道该如何更改。我认为Java文件可能需要定位到/app/src/main/java/cl/rmd/cordova/dialoggps
,但我不确定。