Unity无法使用Admob解决

时间:2019-05-22 08:08:01

标签: c# android unity3d gradle admob

我正在尝试将admob添加到我的统一游戏中,但是解决步骤不起作用 PS:我正在使用由Google提供的项目来尝试admob,因此问题并非出自该项目。

我使用的是unity 5.0.2f1,我下载了this ad sample project,但广告没有展示。 经过一番尝试和错误后,我试图解决,这给了我错误 “ Gradle无法获取依赖项” “无法解决”

这是错误说明:

Gradle failed to fetch dependencies.

Failed to run 'C:\Users\owner\Desktop\HelloWorld\Temp\PlayServicesResolverGradle\gradlew.bat -b "C:\Users\owner\Desktop\HelloWorld\Temp\PlayServicesResolverGradle\PlayServicesResolver.scripts.download_artifacts.gradle" --no-daemon "-PANDROID_HOME=C:/AndroidSDK" "-PTARGET_DIR=C:\Users\owner\Desktop\HelloWorld\Assets\Plugins\Android" "-PMAVEN_REPOS=https://maven.google.com/" "-PPACKAGES_TO_COPY=com.google.android.gms:play-services-ads:17.2.0"'
stdout:
Downloading https://services.gradle.org/distributions/gradle-4.10-bin.zip


stderr:
java.io.IOException: Invalid keystore format
    at sun.security.provider.JavaKeyStore.engineLoad(Unknown Source)
    at sun.security.provider.JavaKeyStore$JKS.engineLoad(Unknown Source)
    at sun.security.provider.KeyStoreDelegator.engineLoad(Unknown Source)
    at sun.security.provider.JavaKeyStore$DualFormatJKS.engineLoad(Unknown Source)
    at java.security.KeyStore.load(Unknown Source)
    at sun.security.util.AnchorCertificates$1.run(Unknown Source)
    at sun.security.util.AnchorCertificates$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.security.util.AnchorCertificates.<clinit>(Unknown Source)
    at sun.security.provider.certpath.AlgorithmChecker.checkFingerprint(Unknown Source)
    at sun.security.provider.certpath.AlgorithmChecker.<init>(Unknown Source)
    at sun.security.provider.certpath.AlgorithmChecker.<init>(Unknown Source)
    at sun.security.validator.SimpleValidator.engineValidate(Unknown Source)
    at sun.security.validator.Validator.validate(Unknown Source)
    at sun.security.validator.Validator.validate(Unknown Source)
    at sun.security.validator.Validator.validate(Unknown Source)
    at javax.crypto.JarVerifier.isTrusted(JarVerifier.java:610)
    at javax.crypto.JarVerifier.verifySingleJar(JarVerifier.java:530)
    at javax.crypto.JarVerifier.verifyJars(JarVerifier.java:363)
    at javax.crypto.JarVerifier.verify(JarVerifier.java:289)
    at javax.crypto.JceSecurity.verifyProviderJar(JceSecurity.java:164)
    at javax.crypto.JceSecurity.getVerificationResult(JceSecurity.java:190)
    at javax.crypto.JceSecurity.canUseProvider(JceSecurity.java:204)
    at javax.crypto.KeyAgreement.getInstance(KeyAgreement.java:179)
    at sun.security.ssl.JsseJce.getKeyAgreement(Unknown Source)
    at sun.security.ssl.JsseJce$EcAvailability.<clinit>(Unknown Source)
    at sun.security.ssl.JsseJce.isEcAvailable(Unknown Source)
    at sun.security.ssl.CipherSuite$KeyExchange.isAvailable(Unknown Source)
    at sun.security.ssl.CipherSuite.isAvailable(Unknown Source)
    at sun.security.ssl.SSLContextImpl.getApplicableCipherSuiteList(Unknown Source)
    at sun.security.ssl.SSLContextImpl.access$100(Unknown Source)
    at sun.security.ssl.SSLContextImpl$AbstractTLSContext.<clinit>(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at java.security.Provider$Service.getImplClass(Unknown Source)
    at java.security.Provider$Service.newInstance(Unknown Source)
    at sun.security.jca.GetInstance.getInstance(Unknown Source)
    at sun.security.jca.GetInstance.getInstance(Unknown Source)
    at javax.net.ssl.SSLContext.getInstance(Unknown Source)
    at javax.net.ssl.SSLContext.getDefault(Unknown Source)
    at javax.net.ssl.SSLSocketFactory.getDefault(Unknown Source)
    at javax.net.ssl.HttpsURLConnection.getDefaultSSLSocketFactory(Unknown Source)
    at javax.net.ssl.HttpsURLConnection.<init>(Unknown Source)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.<init>(Unknown Source)
    at sun.net.www.protocol.https.Handler.openConnection(Unknown Source)
    at sun.net.www.protocol.https.Handler.openConnection(Unknown Source)
    at java.net.URL.openConnection(Unknown Source)
    at org.gradle.wrapper.Download.downloadInternal(Download.java:55)
    at org.gradle.wrapper.Download.download(Download.java:44)
    at org.gradle.wrapper.Install$1.call(Install.java:61)
    at org.gradle.wrapper.Install$1.call(Install.java:48)
    at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65)
    at org.gradle.wrapper.Install.createDist(Install.java:48)
    at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:128)
    at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
Exception in thread "main" java.net.SocketException: java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: Default, provider: SunJSSE, class: sun.security.ssl.SSLContextImpl$DefaultSSLContext)
    at javax.net.ssl.DefaultSSLSocketFactory.throwException(Unknown Source)
    at javax.net.ssl.DefaultSSLSocketFactory.createSocket(Unknown Source)
    at sun.net.www.protocol.https.HttpsClient.createSocket(Unknown Source)
    at sun.net.NetworkClient.doConnect(Unknown Source)
    at sun.net.www.http.HttpClient.openServer(Unknown Source)
    at sun.net.www.http.HttpClient.openServer(Unknown Source)
    at sun.net.www.protocol.https.HttpsClient.<init>(Unknown Source)
    at sun.net.www.protocol.https.HttpsClient.New(Unknown Source)
    at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
    at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown Source)
    at org.gradle.wrapper.Download.downloadInternal(Download.java:58)
    at org.gradle.wrapper.Download.download(Download.java:44)
    at org.gradle.wrapper.Install$1.call(Install.java:61)
    at org.gradle.wrapper.Install$1.call(Install.java:48)
    at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65)
    at org.gradle.wrapper.Install.createDist(Install.java:48)
    at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:128)
    at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
Caused by: java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: Default, provider: SunJSSE, class: sun.security.ssl.SSLContextImpl$DefaultSSLContext)
    at java.security.Provider$Service.newInstance(Unknown Source)
    at sun.security.jca.GetInstance.getInstance(Unknown Source)
    at sun.security.jca.GetInstance.getInstance(Unknown Source)
    at javax.net.ssl.SSLContext.getInstance(Unknown Source)
    at javax.net.ssl.SSLContext.getDefault(Unknown Source)
    at javax.net.ssl.SSLSocketFactory.getDefault(Unknown Source)
    at javax.net.ssl.HttpsURLConnection.getDefaultSSLSocketFactory(Unknown Source)
    at javax.net.ssl.HttpsURLConnection.<init>(Unknown Source)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.<init>(Unknown Source)
    at sun.net.www.protocol.https.Handler.openConnection(Unknown Source)
    at sun.net.www.protocol.https.Handler.openConnection(Unknown Source)
    at java.net.URL.openConnection(Unknown Source)
    at org.gradle.wrapper.Download.downloadInternal(Download.java:55)
    ... 7 more
Caused by: java.io.IOException: Invalid keystore format
    at sun.security.provider.JavaKeyStore.engineLoad(Unknown Source)
    at sun.security.provider.JavaKeyStore$JKS.engineLoad(Unknown Source)
    at sun.security.provider.KeyStoreDelegator.engineLoad(Unknown Source)
    at sun.security.provider.JavaKeyStore$DualFormatJKS.engineLoad(Unknown Source)
    at java.security.KeyStore.load(Unknown Source)
    at sun.security.ssl.TrustManagerFactoryImpl.getCacertsKeyStore(Unknown Source)
    at sun.security.ssl.SSLContextImpl$DefaultManagersHolder.getTrustManagers(Unknown Source)
    at sun.security.ssl.SSLContextImpl$DefaultManagersHolder.<clinit>(Unknown Source)
    at sun.security.ssl.SSLContextImpl$DefaultSSLContext.<init>(Unknown Source)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    ... 20 more

exit code: 1

UnityEngine.Debug:LogError(Object)
Google.Logger:Log(String, LogLevel) (at /Users/smiles/dev/src/unity-jar-resolver/source/VersionHandlerImpl/src/Logger.cs:103)
GooglePlayServices.PlayServicesResolver:Log(String, LogLevel) (at /Users/smiles/dev/src/unity-jar-resolver/source/PlayServicesResolver/src/PlayServicesResolver.cs:757)
GooglePlayServices.<GradleResolution>c__AnonStorey1D:<>m__3A(Result) (at /Users/smiles/dev/src/unity-jar-resolver/source/PlayServicesResolver/src/ResolverVer1_1.cs:849)
GooglePlayServices.<GradleResolution>c__AnonStorey1F:<>m__48() (at /Users/smiles/dev/src/unity-jar-resolver/source/PlayServicesResolver/src/ResolverVer1_1.cs:922)
Google.RunOnMainThread:ExecuteNext() (at /Users/smiles/dev/src/unity-jar-resolver/source/VersionHandlerImpl/src/RunOnMainThread.cs:377)
Google.RunOnMainThread:<ExecuteAll>m__16() (at /Users/smiles/dev/src/unity-jar-resolver/source/VersionHandlerImpl/src/RunOnMainThread.cs:408)
Google.RunOnMainThread:RunAction(Action) (at /Users/smiles/dev/src/unity-jar-resolver/source/VersionHandlerImpl/src/RunOnMainThread.cs:234)
Google.RunOnMainThread:ExecuteAll() (at /Users/smiles/dev/src/unity-jar-resolver/source/VersionHandlerImpl/src/RunOnMainThread.cs:406)
Google.RunOnMainThread:Run(Action, Boolean) (at /Users/smiles/dev/src/unity-jar-resolver/source/VersionHandlerImpl/src/RunOnMainThread.cs:363)
GooglePlayServices.<GradleResolution>c__AnonStorey1D:<>m__3B(Result) (at /Users/smiles/dev/src/unity-jar-resolver/source/PlayServicesResolver/src/ResolverVer1_1.cs:922)
GooglePlayServices.ProgressReporter:SignalComplete() (at /Users/smiles/dev/src/unity-jar-resolver/source/PlayServicesResolver/src/CommandLineDialog.cs:116)
GooglePlayServices.ProgressReporter:CommandLineToolCompletion(Result) (at /Users/smiles/dev/src/unity-jar-resolver/source/PlayServicesResolver/src/CommandLineDialog.cs:107)
GooglePlayServices.<RunAsync>c__AnonStorey2:<>m__4() (at /Users/smiles/dev/src/unity-jar-resolver/source/PlayServicesResolver/src/CommandLine.cs:136)
Google.RunOnMainThread:ExecuteNext() (at /Users/smiles/dev/src/unity-jar-resolver/source/VersionHandlerImpl/src/RunOnMainThread.cs:377)
Google.RunOnMainThread:<ExecuteAll>m__16() (at /Users/smiles/dev/src/unity-jar-resolver/source/VersionHandlerImpl/src/RunOnMainThread.cs:408)
Google.RunOnMainThread:RunAction(Action) (at /Users/smiles/dev/src/unity-jar-resolver/source/VersionHandlerImpl/src/RunOnMainThread.cs:234)
Google.RunOnMainThread:ExecuteAll() (at /Users/smiles/dev/src/unity-jar-resolver/source/VersionHandlerImpl/src/RunOnMainThread.cs:406)
UnityEditor.EditorApplication:Internal_CallUpdateFunctions()

2 个答案:

答案 0 :(得分:0)

我失去了希望,得到了一台新电脑并升级到unity 2019.1.8f1 广告现在可以使用

答案 1 :(得分:0)

问题是您的Java版本没有兼容的根证书,或者没有使用默认的SSL版本,因此您可以从https://services.gradle.org下载gradle。不幸的是,根据所需的gradle和所用的Java版本,可能需要在JDK之间切换。根据一般经验,只要您没有需要旧版本的旧软件,最好就紧跟最新版本的JDK。

您可以在Unity中从“编辑”>“首选项”>“外部工具”之间切换JDK。

希望这可以在将来帮助某人而无需购买整个计算机! ;)