gpt4 book ai didi

android - 广告加载失败,错误代码 0(内部错误) - 华为广告实现

转载 作者:行者123 更新时间:2023-12-04 23:44:48 27 4
gpt4 key购买 nike

我在演示应用程序中不断收到上述错误。我有 HMS 核心版本 5.0.0.329(初始版本)。我的互联网连接很稳定。我已经在应用程序库上创建了测试应用程序,该应用程序已获批准但仍然存在相同的错误。还没有运气。

*Note: This Error only occurs on Huawei Device Y6p - Model- MED-LX9 -Android Version -10.Ads Showing on Samsung S7 - Android Version - 7.0


以下是我的测试应用程序的代码。我正在使用 Android Studio 北极狐 2020.3.1

Module.gradle:

plugins {
id 'com.android.application'
id 'kotlin-android'
id 'com.huawei.agconnect'
}

android {
compileSdk 30

defaultConfig {
applicationId "com.example.huaweitestads"
minSdk 21
targetSdk 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}

dependencies {

implementation 'androidx.core:core-ktx:1.6.0'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

//Huawei Dependency
implementation 'com.huawei.agconnect:agconnect-core:1.5.2.300'
implementation 'com.huawei.hms:ads-lite:13.4.45.308'
//implementation 'com.huawei.hms:ads:3.4.45.308'
implementation 'com.huawei.hms:ads-identifier:3.4.34.301'
}

Project.gradle

    // Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
maven {url 'https://developer.huawei.com/repo/'}
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.0"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21"
classpath 'com.huawei.agconnect:agcp:1.6.0.300'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

setting.gradle

dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
jcenter() // Warning: this repository is going to shut down soon
maven {url 'https://developer.huawei.com/repo/'}
}
}
rootProject.name = "HuaweiTestAds"
include ':app'

MainActivity:

class MainActivity : AppCompatActivity() {
private val adListener: AdListener = object : AdListener(){
override fun onAdClosed() {
showToast("Ad closed")
}

override fun onAdFailed(p0: Int) {
showToast(String.format(Locale.ROOT, "Ad failed to load with error code %d.", p0))
}

override fun onAdLeave() {
showToast("Ad Leave")
}

override fun onAdOpened() {
showToast(String.format("Ad opened "))
}

override fun onAdLoaded() {
showToast("Ad loaded.")
}

override fun onAdClicked() {
showToast("Ad clicked")
}

override fun onAdImpression() {
showToast("Ad Impression")
}
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
//initialize the Huawei Ads
HwAds.init(this)

val bannerView: BannerView? = findViewById(R.id.hw_banner_view)
bannerView!!.adListener = adListener
bannerView.setBannerRefresh(30)
val adParam = AdParam.Builder().build()
bannerView.loadAd(adParam)
}
private fun showToast(message: String) {
Toast.makeText(this, message, Toast.LENGTH_SHORT).show()
}
}

activity.xml

<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:hwads="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/cl_root_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="hello "
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<com.huawei.hms.ads.banner.BannerView
android:id="@+id/hw_banner_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/textView"
hwads:adId="testw6vs28auh3"
hwads:bannerSize="BANNER_SIZE_320_50" />
</androidx.constraintlayout.widget.ConstraintLayout>

logCat Exception:2021-08-27 15:11:48.642 20928-20928/? E/LoadedApk: Unable toinstantiate appComponentFactoryjava.lang.ClassNotFoundException: Didn't find class "androidx.core.app.CoreComponentFactory" on path: DexPathList[[zipfile"/data/app/com.huawei.appmarket-KidEWN7eyzOMAnU7Zs1jjg==/base.apk"],nativeLibraryDirectories=[/data/app/com.huawei.appmarket-KidEWN7eyzOMAnU7Zs1jjg==/lib/arm,/data/app/com.huawei.appmarket-KidEWN7eyzOMAnU7Zs1jjg==/base.apk!/lib/armeabi-v7a,/system/lib, /hw_product/lib, /system/product/lib]]at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:209)at java.lang.ClassLoader.loadClass(ClassLoader.java:379)at java.lang.ClassLoader.loadClass(ClassLoader.java:312)at android.app.LoadedApk.createAppFactory(LoadedApk.java:270)at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:922)at android.app.LoadedApk.getClassLoader(LoadedApk.java:1044)at android.app.LoadedApk.getResources(LoadedApk.java:1293)at android.app.ContextImpl.createAppContext(ContextImpl.java:2610)at android.app.ContextImpl.createAppContext(ContextImpl.java:2598)at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7222)at android.app.ActivityThread.access$2400(ActivityThread.java:308)at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2295)at android.os.Handler.dispatchMessage(Handler.java:110)at android.os.Looper.loop(Looper.java:219)at android.app.ActivityThread.main(ActivityThread.java:8349)at java.lang.reflect.Method.invoke(Native Method)at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1055)


异常(exception) 2:

2021-08-27 15:11:31.275 20725-20779/? E/ServiceRegistrarParser: getServiceDiscoveryexception.ComponentInfo{com.huawei.hms.agclink/com.huawei.agconnect.core.ServiceDiscovery}2021-08-27 15:11:31.298 17647-18622/? E/fwkit_kitProviderDispatcher:[E/fwkit/fwkit_kitProviderDispatcher 17647:4417StubContentProvider.java:153] NameNotFoundExceptionandroid.content.pm.PackageManager$NameNotFoundExceptionat android.app.ApplicationPackageManager.getPackageInfoAsUser(ApplicationPackageManager.java:201)at android.app.ApplicationPackageManager.getPackageInfo(ApplicationPackageManager.java:170)at com.huawei.hms.fwkit.kams.provideragent.a.a(KitProviderDispatcher.java:387)at com.huawei.hms.fwkit.kams.provideragent.a.a(KitProviderDispatcher.java:320)at com.huawei.hms.fwkit.kams.provideragent.StubContentProvider.getType(StubContentProvider.java:153)at android.content.ContentProvider$Transport.getType(ContentProvider.java:295)at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:140)at android.os.Binder.execTransactInternal(Binder.java:1028)at android.os.Binder.execTransact(Binder.java:1001)


异常(exception) 3:

2021-08-27 15:12:07.512 4661-4736/? E/PushLog110102300:[SocketRead_15:10:54-308]read socket occursException: com.huawei.android.pushagent.datatype.exception.PushExceptionra nra* Eiee.ck(Unknown Source:101)ee.run(Unknown Source:40)


任何帮助将不胜感激。谢谢

最佳答案

华为 Y6p 之前在此设备上遇到过同样的问题。您可以检查是否有 SIM 卡。
插入 SIM 卡后,将读取 SIM 卡的国家代码。
国家码获取规则:发货地国家码>sim卡国家码>手机设置国家。

关于android - 广告加载失败,错误代码 0(内部错误) - 华为广告实现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68951757/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com