gpt4 book ai didi

java - Google Play 成就 "IOException: Address already in use"

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:59:17 26 4
gpt4 key购买 nike

新错误

有应用程序工作(加载但声明谷歌播放服务设置不正确)。看着显示器,上面写着 E/ViewRootImpl: sendUserActionEvent() mView == null
并在尝试授予成就时看到以下错误:

07-19 20:51:42.696 16515-16515/com.gfaiers.hangman E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.gfaiers.hangman, PID: 16515
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean com.google.android.gms.common.api.GoogleApiClient.isConnected()' on a null object reference
at com.gfaiers.hangman.HangmanActivity.endGameQuestion(HangmanActivity.java:842)
at com.gfaiers.hangman.HangmanActivity$2.run(HangmanActivity.java:682)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5951)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)

网址:
  • 我已经做了 Hangman Android Studio 中的 Android 游戏。 Code here
  • 我想在游戏中使用成就。
  • 关注 googles guides到目前为止还没有为我工作。
  • 现在做什么?

  • 答案
  • 简单的错别字。严重地。

  • 底部经常更新

    在我开始之前;我是 Android 开发的新手,这是我第一次这样做 - 想象一下我知道的很少!我已经坚持了几天并阅读了很多关于它的文章 - 主要是关于非常相似并说相同内容的文章。另外,我所知道的所有这些文章都已经过时了?

    我见过这些
  • https://developers.google.com/games/services/android/init
  • https://developers.google.com/games/services/android/achievements
  • https://github.com/playgameservices/android-basic-samples/tree/master/BasicSamples

  • 一开始我就一直摔倒……又过了一天,我又走得更远了……
  • Setup Google Play Games Services
  • Gradle version 2.2 is required. Current version is 2.10
  • SDK Location not found Android Studio + Gradle

  • 使用来自 here 的样本时首先他们都说他们

    Updating samples to not use PLUS scope. Also de-linted.



    不确定这实际上意味着什么,但这让我觉得它们已经过时了?知道每件事发生的频率,它们现在已经有 4 个月没有被编辑了(对于这样的东西来说,这是很长的时间吗?)。

    在尝试使用它们时的示例中,我收到以下错误(加载与成就相关联的 TrivialQuest 时):
    Error:Gradle version 2.2 is required. Current version is 2.10. If using the gradle wrapper, try editing the distributionUrl in D:\Users\Geoff\AndroidStudioProjects\android-basic-samples-master\BasicSamples\TrivialQuest\gradle\wrapper\gradle-wrapper.properties to gradle-2.2-all.zip.

    使用包装器时:
    Error:(23, 0) SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.

    在它声明的其他主题中,我需要更改 local.properties 中的目录这已经是正确的。

    我需要帮助的地方:

    我在 PlayStore 上发布了该应用程序已经,我已经起草了成就,我只想让他们使用它。

    我需要帮助找出如何让 BaseGameUtils 在我的应用程序中工作,我已经导入了模块,并关注了 this guide直到“访问其他 Google Play 服务 API”。

    当尝试通过 Android Studio 在模拟器(Nexus 5、SDK23)中运行应用程序时,它会提示我更新 google play 服务(无法在模拟器上完成)。我什至不知道这个消息是从哪里来的,因为在整个应用程序中没有一个字符串,它必须来自谷歌播放服务,它是它自己的。

    在 Galaxy S7edge (6.0.2) 上尝试时,它立即崩溃并显示以下错误:
    06-26 14:46:05.080 2240-2240/com.gfaiers.hangman:background_crash E/InstantRun: IO Error creating local socket at com.gfaiers.hangman java.io.IOException: Address already in use
    at android.net.LocalSocketImpl.bindLocal(Native Method)
    at android.net.LocalSocketImpl.bind(LocalSocketImpl.java:306)
    at android.net.LocalServerSocket.<init>(LocalServerSocket.java:48)
    at com.android.tools.fd.runtime.Server.<init>(Server.java:94)
    at com.android.tools.fd.runtime.Server.create(Server.java:88)
    at com.android.tools.fd.runtime.BootstrapApplication.onCreate(BootstrapApplication.java:358)
    at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1036)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6321)
    at android.app.ActivityThread.access$1800(ActivityThread.java:222)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1861)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:158)
    at android.app.ActivityThread.main(ActivityThread.java:7229)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

    在 Galaxy S4 (5.0.1) 上尝试时,它会挂起一段时间并显示白屏,然后崩溃并且显示器显示:
    06-30 23:56:50.718 2074-2074/com.gfaiers.hangman E/UncaughtException: java.lang.IllegalStateException: A fatal developer error has occurred. Check the logs for further information.
    at com.google.android.gms.common.internal.zzd$zza.zzc(Unknown Source)
    at com.google.android.gms.common.internal.zzd$zza.zzx(Unknown Source)
    at com.google.android.gms.common.internal.zzd$zze.zzasb(Unknown Source)
    at com.google.android.gms.common.internal.zzd$zzd.handleMessage(Unknown Source)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:145)
    at android.app.ActivityThread.main(ActivityThread.java:5951)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)

    ...然后它说
    06-30 23:56:52.160 2074-2074/com.gfaiers.hangman E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.gfaiers.hangman, PID: 2074
    java.lang.IllegalStateException: A fatal developer error has occurred. Check the logs for further information.
    at com.google.android.gms.common.internal.zzd$zza.zzc(Unknown Source)
    at com.google.android.gms.common.internal.zzd$zza.zzx(Unknown Source)
    at com.google.android.gms.common.internal.zzd$zze.zzasb(Unknown Source)
    at com.google.android.gms.common.internal.zzd$zzd.handleMessage(Unknown Source)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:145)
    at android.app.ActivityThread.main(ActivityThread.java:5951)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)
    06-30 23:56:52.290 3331-3331/com.gfaiers.hangman:background_crash D/ResourcesManager: creating new AssetManager and set to /data/app/com.gfaiers.hangman-1/base.apk
    06-30 23:56:52.700 3331-3331/com.gfaiers.hangman:background_crash E/InstantRun: IO Error creating local socket at com.gfaiers.hangman
    java.io.IOException: Address already in use
    at android.net.LocalSocketImpl.bindLocal(Native Method)
    at android.net.LocalSocketImpl.bind(LocalSocketImpl.java:306)
    at android.net.LocalServerSocket.<init>(LocalServerSocket.java:52)
    at com.android.tools.fd.runtime.Server.<init>(Server.java:94)
    at com.android.tools.fd.runtime.Server.create(Server.java:88)
    at com.android.tools.fd.runtime.BootstrapApplication.onCreate(BootstrapApplication.java:358)
    at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1020)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5122)
    at android.app.ActivityThread.access$1600(ActivityThread.java:177)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1510)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:145)
    at android.app.ActivityThread.main(ActivityThread.java:5951)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)

    我的应用程序代码可在 GitHub (MainActivity - where the problems are) 上获得.

    到目前为止,我从指南中所做的代码(我认为问题出在哪里):
    private GoogleApiClient mGoogleApiClient;
    private static int RC_SIGN_IN = 9001;
    private boolean mResolvingConnectionFailure = false;
    private boolean mAutoStartSignInFlow = true;
    private boolean mSignInClicked = false;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    // Create the Google Api Client with access to the Play Games services
    mGoogleApiClient = new GoogleApiClient.Builder(this)
    .addConnectionCallbacks(this)
    .addOnConnectionFailedListener(this)
    .addApi(Games.API).addScope(Games.SCOPE_GAMES)
    // add other APIs and scopes here as needed
    .build();
    ...
    @Override
    public void onConnected(Bundle connectionHint) {
    // The player is signed in. Hide the sign-in button and allow the
    // player to proceed.
    }

    @Override
    public void onConnectionFailed(ConnectionResult connectionResult) {
    if (mResolvingConnectionFailure) {
    // already resolving
    return;
    }

    // if the sign-in button was clicked or if auto sign-in is enabled,
    // launch the sign-in flow
    if (mSignInClicked || mAutoStartSignInFlow) {
    mAutoStartSignInFlow = false;
    mSignInClicked = false;
    mResolvingConnectionFailure = true;

    // Attempt to resolve the connection failure using BaseGameUtils.
    // The R.string.sign_in_other_error value should reference a generic
    // error string in your strings.xml file, such as "There was
    // an issue with sign-in, please try again later."
    if (!BaseGameUtils.resolveConnectionFailure(this,
    mGoogleApiClient, connectionResult,
    RC_SIGN_IN, getResources().getString(R.string.sign_in_other_error))) {
    mResolvingConnectionFailure = false;
    }
    }

    // Put code here to display the sign-in button
    }

    @Override
    public void onConnectionSuspended(int i) {
    // Attempt to reconnect
    mGoogleApiClient.connect();
    }

    protected void onActivityResult(int requestCode, int resultCode,
    Intent intent) {
    if (requestCode == RC_SIGN_IN) {
    mSignInClicked = false;
    mResolvingConnectionFailure = false;
    if (resultCode == RESULT_OK) {
    mGoogleApiClient.connect();
    } else {
    // Bring up an error dialog to alert the user that sign-in
    // failed. The R.string.sign_in_failure should reference an error
    // string in your strings.xml file that tells the user they
    // could not be signed in, such as "Unable to sign in."
    BaseGameUtils.showActivityResultError(this,
    requestCode, resultCode, R.string.sign_in_failure);
    }
    }
    }

    // Call when the sign-in button is clicked
    private void signInClicked() {
    mSignInClicked = true;
    mGoogleApiClient.connect();
    }

    // Call when the sign-out button is clicked
    private void signOutClicked() {
    mSignInClicked = false;
    Games.signOut(mGoogleApiClient);
    }

    GitHub 上的代码全部更新。

    我还添加到 BaseGameUtils build.gradle 文件:
    ...buildToolsVersion android_version

    defaultConfig {
    minSdkVersion 17
    }

    这似乎是解决构建失败的解决方案,说 minSdkVersion 1 对于库版本 7 等来说太低了。

    最新更新

    在阅读了更多内容之后,我发现了一些看起来非常简单的应用程序 AndroidManifest 中的解决方案(而不是 lib)。
    <!--<meta-data android:name="com.gooogle.android.gms.games.APP_ID" android:value="@string/app_id"/>-->

    我把评论标记去掉了,还是显示上面的错误“A致命的开发者错误”。我把它改成:
    <meta-data android:name="com.gooogle.android.gms.games.com.gfaiers.hangman" android:value="@string/app_id"/>

    完全不确定这是否是我想要做的,它仍然犯了同样的错误。

    但是进一步阅读……它指出:
    07-01 22:15:02.196 24277-24277/com.gfaiers.hangman D/FirebaseCrashApiImpl: throwable java.lang.IllegalStateException: A fatal developer error has occurred. Check the logs for further information.

    这会让我认为是 AdMob 导致了崩溃?!

    请求的 local.properties 文件
    ndk.dir=D\:\\Users\\Geoff\\AppData\\Local\\Android\\Sdk\\ndk-bundle
    sdk.dir=D\:\\Users\\Geoff\\AppData\\Local\\Android\\Sdk

    到目前为止答案的更新

    将依赖项更改为:
    dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile project(':BaseGameUtils')
    compile 'com.android.support:appcompat-v7:24.0.0'
    compile 'com.android.support:support-v4:24.0.0'
    compile 'com.google.firebase:firebase-ads:9.2.0'
    compile 'com.google.android.gms:play-services-ads:9.2.0'
    compile 'com.google.android.gms:play-services-auth:9.2.0'
    compile 'com.google.android.gms:play-services-gcm:9.2.0'
    compile 'com.google.android.gms:play-services-games:9.2.0'

    错误现在显示为:
    07-02 09:36:16.061 2133-7644/? E/Ads: Error transporting the ad response
    java.io.IOException: write failed: EPIPE (Broken pipe)
    at libcore.io.IoBridge.write(IoBridge.java:502)
    at java.io.FileOutputStream.write(FileOutputStream.java:186)
    at java.io.DataOutputStream.write(DataOutputStream.java:98)
    at java.io.OutputStream.write(OutputStream.java:82)
    at com.google.android.gms.ads.internal.request.ac.run(:com.google.android.gms:150)
    at java.lang.Thread.run(Thread.java:818)
    Caused by: android.system.ErrnoException: write failed: EPIPE (Broken pipe)
    at libcore.io.Posix.writeBytes(Native Method)
    at libcore.io.Posix.write(Posix.java:223)
    at libcore.io.BlockGuardOs.write(BlockGuardOs.java:313)
    at libcore.io.IoBridge.write(IoBridge.java:497)
    at java.io.FileOutputStream.write(FileOutputStream.java:186) 
    at java.io.DataOutputStream.write(DataOutputStream.java:98) 
    at java.io.OutputStream.write(OutputStream.java:82) 
    at com.google.android.gms.ads.internal.request.ac.run(:com.google.android.gms:150)
    at java.lang.Thread.run(Thread.java:818) 

    最佳答案

    只是在黑暗中的一个镜头,但这可能是解决一些问题的第一步......

    在您的 gradle 构建文件中,您要求包含所有 Google Play 服务:

    dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile project(':BaseGameUtils')
    compile 'com.android.support:appcompat-v7:24.0.0'
    compile 'com.android.support:support-v4:24.0.0'
    compile 'com.google.android.gms:play-services:9.2.0' <-- NOT GOOD
    compile 'com.google.firebase:firebase-ads:9.0.0'
    compile 'com.google.android.gms:play-services-ads:9.2.0'
    compile 'com.google.android.gms:play-services-auth:9.2.0'
    compile 'com.google.android.gms:play-services-gcm:9.2.0'
    }

    这会引入许多您可能没有使用和不需要的功能。您将获得所有 Play 服务和 Firebase libraries .特别是,您可以获得新的 Firebase 崩溃报告,它仍处于测试阶段。我在您的一些堆栈跟踪中看到包含标签 background_crash 的条目。这是崩溃报告组件之一。

    许多人(包括我自己)都遇到过由于拉入所有 PlayServices/Firebase 而导致应用程序挂起的问题。 See this related issue .

    作为起点,我建议编辑您的依赖项以删除 play-services:9.2.0然后仅保留或添加使您的应用程序成功构建所需的特定库。它可能不会解决所有崩溃问题,但可能会有所帮助。另外,我认为您会发现您的应用程序构建速度更快,生成的 APK 更小。

    更新

    您的崩溃调用堆栈之一与 this related issue 中的类似。 .该崩溃是由于未定义 APP_ID 的元数据造成的。我没有你的 list 中定义的元数据。你不需要吗?添加它是此 guide for using Games Services 中的步骤之一.

    更新 2

    我确认问题是缺少 APP_ID 的元数据。你曾经在你的 AndroidManifest 文件中有它,但有一个错字。你在谷歌中有一个额外的“o”:

    com.gooogle.android.gms.games.APP_ID



    取消注释 list 中的元数据并更正错字。然后应用程序应该可以运行而不会崩溃。它对我有用。
    <application
    android:allowBackup="true"
    android:icon="@mipmap/icon"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/NoActionBar">
    <meta-data
    android:name="com.google.android.gms.games.APP_ID" <-- typo was here
    android:value="@string/app_id"/>

    如果它仍然崩溃,请查看未过滤的 logcat 输出。要做到这一点,请选择 No Filters在 Android Monitor 窗口中.. 如果 APP_ID 元数据仍然存在问题,您将看到以下消息:
     E/ValidateServiceOp: Using Google Play games services requires a metadata tag with the name "com.google.android.gms.games.APP_ID" in the application tag of the manifest for com.gfaiers.hangman

    您可能还想进一步清理构建依赖项:
    dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile project(':BaseGameUtils')
    compile 'com.android.support:appcompat-v7:24.0.0'
    compile 'com.android.support:support-v4:24.0.0'
    compile 'com.google.firebase:firebase-ads:9.2.0'
    //compile 'com.google.android.gms:play-services-ads:9.2.0'
    //compile 'com.google.android.gms:play-services-auth:9.2.0'
    //compile 'com.google.android.gms:play-services-gcm:9.2.0'
    compile 'com.google.android.gms:play-services-games:9.2.0'
    }

    关于java - Google Play 成就 "IOException: Address already in use",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38039211/

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