Javascript 无法使Nativescript插件正常工作;nativescript admob“;
我已经在SDK管理器Extras中安装了必备的“Google play service”。运行时,emulator上会显示应用程序页面,但不显示横幅,CLI日志显示错误。谁能告诉我我错过了什么Javascript 无法使Nativescript插件正常工作;nativescript admob“;,javascript,android,admob,google-play-services,nativescript,Javascript,Android,Admob,Google Play Services,Nativescript,我已经在SDK管理器Extras中安装了必备的“Google play service”。运行时,emulator上会显示应用程序页面,但不显示横幅,CLI日志显示错误。谁能告诉我我错过了什么 admob.createBanner({ // if this 'view' property is not set, the banner is overlayed on the current top most view // view: ..,
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 android调试。这样,您可以看到导致此错误的原因: 无法读取null的属性“android” 在我看来,您调用admob太早了,而且并非所有内容都已初始化。无论如何,只需调试它:)
希望这有帮助。我的建议是简单地使用tns android调试。这样,您可以看到导致此错误的原因: 无法读取null的属性“android” 在我看来,您调用admob太早了,而且并非所有内容都已初始化。无论如何,只需调试它:)
希望这能有所帮助。没错,也许要早点。我把它放在页面导航功能中,可能没有足够的时间初始化。当我在点击按钮中移动它时,它只需点击即可工作。但我的问题是现在我想在页面启动时加载它。Nativescript是否有类似于页面加载的功能,或者什么是定位它的最佳方式?当然。只需检查他们的文档。比在SO上发布更快;)当然,您导出的函数应该是pageLoaded,这是正确的,可能是早期的。我把它放在页面导航功能中,可能没有足够的时间初始化。当我在点击按钮中移动它时,它只需点击即可工作。但我的问题是现在我想在页面启动时加载它。Nativescript是否有类似于页面加载的功能,或者什么是定位它的最佳方式?当然。只需检查他们的文档。比在SO上发布更快;)当然,您导出的函数应该被分页加载
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)