Oracle JET:启动 android 的 ojet 混合应用程序时出错

Oracle JET: Getting error while launching ojet hybrid app for android

Android 模拟器在我们启动裸机应用程序时显示错误,请参阅随附的屏幕截图。 它按预期工作 iOS。

我已经尝试了所有默认模板 navbar、navdrawer 和 blank。

screenshot

这是一个直接从入门页面开始的应用程序,没有对模板代码进行任何修改。

Last login: Wed Aug 26 11:02:18 on ttys000

~                                                                              
▶ cd Desktop 

~/Desktop                                                                      
▶ ojet create myapp --template= navbar:hybrid

~/Desktop                                                                      
▶ cd myapp 

~/Desktop/myapp                                                                
▶ ojet add hybrid
? Please choose the platforms you want to install Android, iOS
Adding platform: android
Using cordova-fetch for cordova-android@^9.0.0


Adding android project...


Creating Cordova project for the Android platform:

    Path: platforms/android
    Package: org.oraclejet.myapp
    Name: myapp
    Activity: MainActivity
    Android target: android-29


Subproject Path: CordovaLib

Subproject Path: app

Android project created with cordova-android@9.0.0

Discovered plugin "cordova-plugin-whitelist". Adding it to the project


Installing "cordova-plugin-whitelist" for android

Adding cordova-plugin-whitelist to package.json


Adding platform: ios
Using cordova-fetch for cordova-ios@^6.1.0


Adding ios project...


Creating Cordova project for the iOS platform:

    Path: platforms/ios
    Package: org.oraclejet.myapp
    Name: myapp

iOS project created with cordova-ios@6.1.0


Installing "cordova-plugin-whitelist" for ios

Adding platform: browser
Using cordova-fetch for cordova-browser@^6.0.0


Adding browser project...


Creating Cordova project for cordova-browser:

    Path: /Users/hellonuh/Desktop/myapp/hybrid/platforms/browser
    Name: myapp

Installing "cordova-plugin-whitelist" for browser

6.0.0

Add hybrid finished.

~/Desktop/myapp                                                                
▶ ojet serve android                         
Build: true
BuildType: dev
Destination: emulator
Destination target: undefined
Livereload: true
Livereload port: 35729
Platform: android
Theme: redwood
Theme platform: android
Theme version: 9.1.0
Building app.
Cleaning staging path.
Running before_build hook.
Copy files to staging directory.
Copy finished.
Copy library files to staging directory.
Copy finished.
Copy reference components to staging directory.
Copy finished.
Copy local web components
Copy local web components skipped
Optimizing svg into SVG sprites.
Svg optimization task finished.
Compiling sass...
Sass compile finished.
Task index.html cdn bundle injection finished.
Running theme copy task.
Theme copy task finished.
Running theme injection task.
Task index.html theme path injection finished.
Injecting index.html with cordova script.
Running injection tasks.
Task main.js paths injection finished.
runAllComponentHooks 
Running after_build hook.
Running before_serve hook.
Executing: cordova clean android
Checking Java JDK and Android SDK versions

ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=undefined (DEPRECATED)

Using Android SDK: /Users/hellonuh/Library/Android/sdk

> Task :wrapper


BUILD SUCCESSFUL in 1s
1 actionable task: 1 executed


Subproject Path: CordovaLib


Subproject Path: app


> Task :clean UP-TO-DATE

> Task :app:clean UP-TO-DATE
> Task :CordovaLib:clean
 UP-TO-DATE


BUILD SUCCESSFUL
 in 1s

3 actionable tasks: 3 up-to-date

child process exited with code: 0
Executing: cordova serve 
Plugin 'cordova-plugin-wkwebview-file-xhr' found in config.xml... Migrating it to package.json


Plugin 'cordova-plugin-wkwebview-engine' found in config.xml... Migrating it to package.json


Discovered plugin "cordova-plugin-wkwebview-file-xhr". Adding it to the project


Installing "cordova-plugin-wkwebview-file-xhr" for android


Installing "cordova-plugin-wkwebview-engine" for android


Failed to install 'cordova-plugin-wkwebview-engine': Error: ENOENT: no such file or directory, open '/Users/hellonuh/Desktop/myapp/hybrid/platforms/android/app/src/main/assets/www/cordova_plugins.js'
    at Object.openSync (fs.js:462:3)
    at Object.writeFileSync (fs.js:1362:35)
    at /Users/hellonuh/Desktop/myapp/hybrid/node_modules/cordova-common/src/PluginManager.js:132:20
    at _fulfilled (/Users/hellonuh/Desktop/myapp/hybrid/node_modules/q/q.js:854:54)
    at /Users/hellonuh/Desktop/myapp/hybrid/node_modules/q/q.js:883:30
    at Promise.promise.promiseDispatch (/Users/hellonuh/Desktop/myapp/hybrid/node_modules/q/q.js:816:13)
    at /Users/hellonuh/Desktop/myapp/hybrid/node_modules/q/q.js:877:14
    at runSingle (/Users/hellonuh/Desktop/myapp/hybrid/node_modules/q/q.js:137:13)
    at flush (/Users/hellonuh/Desktop/myapp/hybrid/node_modules/q/q.js:125:13)
    at processTicksAndRejections (internal/process/task_queues.js:79:11)


Failed to install 'cordova-plugin-wkwebview-file-xhr': Error: ENOENT: no such file or directory, open '/Users/hellonuh/Desktop/myapp/hybrid/platforms/android/app/src/main/assets/www/cordova_plugins.js'
    at Object.openSync (fs.js:462:3)
    at Object.writeFileSync (fs.js:1362:35)
    at /Users/hellonuh/Desktop/myapp/hybrid/node_modules/cordova-common/src/PluginManager.js:132:20
    at _fulfilled (/Users/hellonuh/Desktop/myapp/hybrid/node_modules/q/q.js:854:54)
    at /Users/hellonuh/Desktop/myapp/hybrid/node_modules/q/q.js:883:30
    at Promise.promise.promiseDispatch (/Users/hellonuh/Desktop/myapp/hybrid/node_modules/q/q.js:816:13)
    at /Users/hellonuh/Desktop/myapp/hybrid/node_modules/q/q.js:877:14
    at runSingle (/Users/hellonuh/Desktop/myapp/hybrid/node_modules/q/q.js:137:13)
    at flush (/Users/hellonuh/Desktop/myapp/hybrid/node_modules/q/q.js:125:13)
    at processTicksAndRejections (internal/process/task_queues.js:79:11)


Failed to restore plugin "cordova-plugin-wkwebview-file-xhr". You might need to try adding it again. Error: Error: ENOENT: no such file or directory, open '/Users/hellonuh/Desktop/myapp/hybrid/platforms/android/app/src/main/assets/www/cordova_plugins.js'


Static file server running on: http://localhost:8000 (CTRL + C to shut down)
Executing: cordova run android --emulator --debug


Checking Java JDK and Android SDK versions

ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=undefined (DEPRECATED)

Using Android SDK: /Users/hellonuh/Library/Android/sdk

Subproject Path: CordovaLib


Subproject Path: app

> Task :app:preBuild UP-TO-DATE

> Task :app:preDebugBuild UP-TO-DATE

> Task :CordovaLib:preBuild UP-TO-DATE


> Task :CordovaLib:preDebugBuild
 UP-TO-DATE

> Task :CordovaLib:compileDebugAidl NO-SOURCE
> Task :app:compileDebugAidl NO-SOURCE
> Task :CordovaLib:packageDebugRenderscript
 NO-SOURCE

> Task :app:compileDebugRenderscript NO-SOURCE

> Task :app:generateDebugBuildConfig

> Task :app:generateDebugResValues
> Task :app:generateDebugResources


> Task :CordovaLib:compileDebugRenderscript

> Task :CordovaLib:generateDebugResValues
> Task :CordovaLib:generateDebugResources
> Task :CordovaLib:packageDebugResources

> Task :app:createDebugCompatibleScreenManifests

> Task :app:extractDeepLinksDebug
> Task :CordovaLib:extractDeepLinksDebug
> Task :app:javaPreCompileDebug

> Task :CordovaLib:compileDebugLibraryResources


> Task :CordovaLib:generateDebugBuildConfig

> Task :app:mergeDebugShaders
> Task :app:compileDebugShaders NO-SOURCE
> Task :app:generateDebugAssets
 UP-TO-DATE
> Task :CordovaLib:mergeDebugShaders
> Task :CordovaLib:compileDebugShaders NO-SOURCE
> Task :CordovaLib:generateDebugAssets
 UP-TO-DATE
> Task :CordovaLib:packageDebugAssets

> Task :app:mergeDebugAssets

> Task :app:processDebugJavaRes NO-SOURCE
> Task :CordovaLib:processDebugJavaRes NO-SOURCE

> Task :CordovaLib:bundleLibResDebug NO-SOURCE

> Task :app:checkDebugDuplicateClasses
> Task :app:desugarDebugFileDependencies
> Task :app:mergeDebugJavaResource
> Task :app:mergeDebugJniLibFolders

> Task :CordovaLib:mergeDebugJniLibFolders
> Task :app:validateSigningDebug

> Task :app:mergeExtDexDebug

> Task :CordovaLib:mergeDebugNativeLibs

> Task :CordovaLib:stripDebugDebugSymbols
 NO-SOURCE

> Task :CordovaLib:copyDebugJniLibsProjectOnly

> Task :CordovaLib:parseDebugLocalResources


> Task :CordovaLib:javaPreCompileDebug

> Task :CordovaLib:processDebugManifest

> Task :app:processDebugManifest
> Task :app:mergeDebugResources
> Task :CordovaLib:generateDebugRFile

> Task :app:processDebugResources


> Task :CordovaLib:compileDebugJavaWithJavac
> Task :app:mergeDebugNativeLibs
> Task :app:stripDebugDebugSymbols NO-SOURCE
> Task :CordovaLib:bundleLibCompileToJarDebug

> Task :app:compileDebugJavaWithJavac

> Task :app:compileDebugSources
> Task :CordovaLib:bundleLibRuntimeToJarDebug

> Task :app:dexBuilderDebug

> Task :app:mergeProjectDexDebug

> Task :app:mergeLibDexDebug


> Task :app:packageDebug

> Task :app:assembleDebug
> Task :app:cdvBuildDebug



Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.5/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 6s

40 actionable tasks: 40 executed

Built the following apk(s): 
    /Users/hellonuh/Desktop/myapp/hybrid/platforms/android/app/build/outputs/apk/debug/app-debug.apk


Checking Java JDK and Android SDK versions

ANDROID_SDK_ROOT=/Users/hellonuh/Library/Android/sdk (recommended setting)
ANDROID_HOME=undefined (DEPRECATED)

Using Android SDK: /Users/hellonuh/Library/Android/sdk

Using apk: /Users/hellonuh/Desktop/myapp/hybrid/platforms/android/app/build/outputs/apk/debug/app-debug.apk

Package name: org.oraclejet.myapp

INSTALL SUCCESS


LAUNCH SUCCESS
Starting watcher.
Running after_serve hook.
(node:3931) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'liveReloadServer' of undefined
    at /Users/hellonuh/Desktop/myapp/node_modules/@oracle/oraclejet-tooling/lib/serve/watch.js:65:28
    at new Promise (<anonymous>)
    at _startLiveReloadServer (/Users/hellonuh/Desktop/myapp/node_modules/@oracle/oraclejet-tooling/lib/serve/watch.js:64:10)
    at /Users/hellonuh/Desktop/myapp/node_modules/@oracle/oraclejet-tooling/lib/serve/watch.js:40:7
    at new Promise (<anonymous>)
    at module.exports (/Users/hellonuh/Desktop/myapp/node_modules/@oracle/oraclejet-tooling/lib/serve/watch.js:38:10)
    at /Users/hellonuh/Desktop/myapp/node_modules/@oracle/oraclejet-tooling/lib/serveHybrid.js:42:9
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:3931) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:3931) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.


child process exited with code: 0
^C

~/Desktop/myapp                                                               ⍉
▶ ojet serve ios                             
^C

~/Desktop/myapp                                                               ⍉
▶ 

以下解决方案对我有用

ojet add plugins cordova-plugin-cleartext
ojet build android
ojet serve android  

无需向您的应用添加额外的插件。 您只需将此行添加到您的 AndroidManifest.xml 文件中即可。 这应该只在开发期间需要,因为一旦您使用 --release 发布应用程序,它将使用 https 而不会使用明文。

标签内,添加

AndroidManifest.xml 文件默认位于

/hybrid/platforms/android/app/src/main

如果您正在阅读本文并且上述解决方案对您不起作用,您可以应用这个对我有用的变通办法,转至:

/node_modules/@oracle/oraclejet-tooling/lib

在 JS 文件的那个文件夹中:serveHybrid.js 搜索:(在我的例子中是第 42 行):

if (serveOptions.livereload) {
    serveWatch(serveOptions.watch, serveOptions.livereloadPort);

添加为 serveWatch 的参数,serveOptions:

serveWatch(serveOptions.watch, serveOptions.livereloadPort, serveOptions);

这对我有用,解决了 liveReload 问题。

此致。