我已经在SDK Manager Extras中安装了必备的“ Google Play服务”。运行时,“应用程序”页面显示在模拟器上,没有横幅,CLI日志显示错误。谁能告诉我我想念什么?
admob.createBanner({
// if this 'view' property is not set, the banner is overlayed on the current top most view
// view: ..,
testing: true, // set to false to get real banners
size: admob.AD_SIZE.SMART_BANNER, // anything in admob.AD_SIZE, like admob.AD_SIZE.SMART_BANNER
iosBannerId: "ca-app-pub-XXXXXX/YYYYYY", // add your own
androidBannerId: "ca-app-pub-9495738740700511/5085446949", // add your own
// Android automatically adds the connected device as test device with testing:true, iOS does not
iosTestDeviceIds: ["yourTestDeviceUDIDs", "EAA5B49DBA3AD30CC27A343C86CD7ADF"],
margins: {
// if both are set, top wins
//top: 10
bottom: 50
}
}).then(
function() {
console.log("admob createBanner done");
},
function(error) {
console.log("admob createBanner error: " + error);
}
)
我创建了新项目“ tns create adtest”
添加了插件“ tns插件添加了nativescript-admob”
添加平台“ tns平台添加android”
由“ tns livesync android --watch”运行
-错误记录-
Project successfully prepared
The application with id "org.nativescript.adtest" is not installed on device with identifier emulator-5554.
Project successfully prepared
WARNING: The file: D:\GoogleDrive\PROJECTS\adtest\node_modules\nativescript-admob\platforms\android\AndroidManifest.xml is depricated, you can read more about what will be the expected plugin structure here: https://www.nativescript.org/blog/migrating-n-android-plugins-from-version-1.7-to-2.0
:config phase: createDefaultIncludeFiles
+found plugins: nativescript-admob
{
"F0" {
dimension "nativescriptadmob"
}
}
} +found plugins: tns-core-modules-widgets
{
"F1" {
dimension "tnscoremoduleswidgets"
}
}
}
:config phase: createPluginsConfigFile
Creating product flavors include.gradle file in D:\GoogleDrive\PROJECTS\adtest\platforms\android/configurations folder...
:config phase: pluginExtend
+applying configuration from: D:\GoogleDrive\PROJECTS\adtest\platforms\android\configurations\include.gradle
+applying configuration from: D:\GoogleDrive\PROJECTS\adtest\platforms\android\configurations\nativescript-admob\include.gradle
+applying configuration from: D:\GoogleDrive\PROJECTS\adtest\platforms\android\configurations\tns-core-modules-widgets\include.gradle
:config phase: copyAarDependencies
:config phase: addAarDependencies
+adding dependency: D:\GoogleDrive\PROJECTS\adtest\platforms\android\libs\aar\widgets-release.aar
:preBuild UP-TO-DATE
:preF0F1DebugBuild UP-TO-DATE
:checkF0F1DebugManifest
:preF0F1ReleaseBuild UP-TO-DATE
:prepareComAndroidSupportAnimatedVectorDrawable2330Library
:prepareComAndroidSupportAppcompatV72330Library
:prepareComAndroidSupportSupportV42330Library
:prepareComAndroidSupportSupportVectorDrawable2330Library
:prepareComGoogleAndroidGmsPlayServicesAds840Library
:prepareComGoogleAndroidGmsPlayServicesBasement840Library
:prepareWidgetsReleaseLibrary
:prepareF0F1DebugDependencies
:compileF0F1DebugAidl UP-TO-DATE
:compileF0F1DebugRenderscript UP-TO-DATE
:generateF0F1DebugBuildConfig UP-TO-DATE
:cleanLocalAarFiles
:ensureMetadataOutDir
:collectAllJars
:setProperties
:asbg:generateInterfaceNamesList
:asbg:runAstParser UP-TO-DATE
:asbg:generateBindings UP-TO-DATE
:generateF0F1DebugAssets UP-TO-DATE
:mergeF0F1DebugAssets
:generateF0F1DebugResValues UP-TO-DATE
:generateF0F1DebugResources UP-TO-DATE
:mergeF0F1DebugResources UP-TO-DATE
:processF0F1DebugManifest UP-TO-DATE
:processF0F1DebugResources
:generateF0F1DebugSources
:compileF0F1DebugJavaWithJavac UP-TO-DATE
:compileF0F1DebugNdk UP-TO-DATE
:compileF0F1DebugSources UP-TO-DATE
:buildMetadata UP-TO-DATE
:transformClassesWithDexForF0F1Debug UP-TO-DATE
:mergeF0F1DebugJniLibFolders UP-TO-DATE
:transformNative_libsWithMergeJniLibsForF0F1Debug UP-TO-DATE
:processF0F1DebugJavaRes UP-TO-DATE
:transformResourcesWithMergeJavaResForF0F1Debug UP-TO-DATE
:validateDebugSigning
:packageF0F1Debug
:zipalignF0F1Debug
:assembleF0F1Debug
:assembleDebug
:deleteExplodedAarFolder UP-TO-DATE
:buildapk
BUILD SUCCESSFUL
Total time: 11.657 secs
Project successfully built
JS: Treating this deviceId as testdevice: CA5F7DA5D57FD0D05E676D0CD880FB80
chromium: [INFO:library_loader_hooks.cc(120)] Chromium logging enabled: level = 0, default verbosity = 0
05-06 03:27:04.304 3124 3124 I BrowserStartupController: Initializing chromium process, singleProcess=true
chromium: [WARNING:resource_bundle.cc(285)] locale_file_path.empty()
05-06 03:27:04.349 3124 3124 E DataReductionProxySettingListener: No DRP key due to exception:java.lang.ClassNotFoundException: com.android.webview.chromium.Drp
JS: Error in admob.createBanner: TypeError: Cannot read property 'android' of null
JS: admob createBanner error: TypeError: Cannot read property 'android' of null
chromium: [WARNING:data_reduction_proxy_config.cc(423)] SPDY proxy OFF at startup
chromium: [INFO:CONSOLE(0)] "Creating Application Cache with manifest https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40.appcache", source: https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40.html (0)
chromium: [INFO:CONSOLE(0)] "Application Cache Checking event", source: https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40.html (0)
chromium: [INFO:CONSOLE(0)] "Application Cache Downloading event", source: https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40.html (0)
chromium: [INFO:CONSOLE(0)] "Application Cache Progress event (0 of 4) https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40.js", source: https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40.html (0)
chromium: [INFO:CONSOLE(0)] "Application Cache Progress event (1 of 4) https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/production/sdk-core-v40-impl.js", source: https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40.html (0)
chromium: [INFO:CONSOLE(0)] "Application Cache Progress event (2 of 4) https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/canary/sdk-core-v40-impl.js", source: https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40.html (0)
chromium: [INFO:CONSOLE(0)] "Application Cache Progress event (3 of 4) https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/native_ads.js", source: https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40.html (0)
chromium: [INFO:CONSOLE(0)] "Document was loaded from Application Cache with manifest https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40.appcache", source: https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40.html (0)
chromium: [INFO:CONSOLE(0)] "Application Cache Checking event", source: https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40.html (0)
chromium: [INFO:CONSOLE(0)] "Application Cache NoUpdate event", source: https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40.html (0)
最佳答案
我的建议是简单地使用tns android debug。这样,您可以查看导致此错误的原因:
无法读取null的属性“ android”
在我看来,您打电话给admob的时间太早了,还没有初始化一切。无论如何,只需调试它即可:)
希望这可以帮助。
关于javascript - 无法获取Nativescript插件以运行“nativescript-admob”,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/37062272/