反应本机:错误:资源android:style/TextAppearance.Material.Widget.Button.Borderless.Colored未找到

反应本机:错误:资源android:style/TextAppearance.Material.Widget.Button.Borderless.Colored未找到,android,reactjs,android-studio,react-native,Android,Reactjs,Android Studio,React Native,我正在尝试为我的React Native Android项目登录Facebook,当我尝试使用React Native run Android构建它时,我遇到了这个错误 起初我认为这是我的Gradle版本的问题,因为React Native安装了Gradle 2.14,后来我升级到了Gradle 4.4 我多次翻阅Facebook安装指南,但仍然发现这个错误。我还对我的代码进行了三次检查,以确保我没有使用任何错误的字体/fontWeight/fontStyle。我能想到的唯一一件事就是来自标准组

我正在尝试为我的React Native Android项目登录Facebook,当我尝试使用React Native run Android构建它时,我遇到了这个错误

起初我认为这是我的Gradle版本的问题,因为React Native安装了Gradle 2.14,后来我升级到了Gradle 4.4

我多次翻阅Facebook安装指南,但仍然发现这个错误。我还对我的代码进行了三次检查,以确保我没有使用任何错误的字体/fontWeight/fontStyle。我能想到的唯一一件事就是来自标准组件的Facebook按钮中有不受支持的样式?我不确定

任何帮助都将不胜感激。我做这件事的时间比我想承认的要长

MainActivity.java文件

package com.myproj;

import android.content.Intent;
import com.facebook.react.ReactActivity;
import com.facebook.reactnative.androidsdk.FBSDKPackage;
import com.facebook.FacebookSdk;

public class MainActivity extends ReactActivity {

    /**
     * Returns the name of the main component registered from JavaScript.
     * This is used to schedule rendering of the component.
     */
    @Override
    protected String getMainComponentName() {
        return "myproj";
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        MainApplication.getCallbackManager().onActivityResult(requestCode, resultCode, data);
    }
}
MainApplication.java文件

package com.myproj;

import android.app.Application;

import com.facebook.react.ReactApplication;
import com.facebook.reactnative.androidsdk.FBSDKPackage;
import com.facebook.reactnative.androidsdk.FBSDKPackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
import com.facebook.CallbackManager;
import com.facebook.FacebookSdk;
import com.facebook.appevents.AppEventsLogger;





import java.util.Arrays;
import java.util.List;

public class MainApplication extends Application implements ReactApplication {

   private static CallbackManager mCallbackManager = CallbackManager.Factory.create();

   protected static CallbackManager getCallbackManager() {
     return mCallbackManager;
   }

  private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
    @Override
    public boolean getUseDeveloperSupport() {
      return BuildConfig.DEBUG;
    }


    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
          new MainReactPackage(),
          new FBSDKPackage(mCallbackManager)
      );
    }

    @Override
    protected String getJSMainModuleName() {
      return "index";
    }
  };

  @Override
  public ReactNativeHost getReactNativeHost() {
    return mReactNativeHost;
  }

  @Override
  public void onCreate() {
    super.onCreate();
    AppEventsLogger.activateApp(this);

  }

}
我收到的错误:

> Configure project :app 
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation'.
It will be removed at the end of 2018

> Configure project :react-native-fbsdk 
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation'.
It will be removed at the end of 2018
WARNING: The specified Android SDK Build Tools version (26.0.2) is ignored, as it is below the minimum supported version (27.0.3) for Android Gradle Plugin 3.1.0.
Android SDK Build Tools 27.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '26.0.2'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.

error: resource android:style/TextAppearance.Material.Widget.Button.Borderless.Colored not found.
error: resource android:style/TextAppearance.Material.Widget.Button.Colored not found.
/Users/me/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.0.2.aar/a1a4a045a3ea2f70ae16170c81e2001d/res/values-v26/values-v26.xml:9:5-12:13: AAPT: error: resource android:attr/colorError not found.

/Users/me/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.0.2.aar/a1a4a045a3ea2f70ae16170c81e2001d/res/values-v26/values-v26.xml:13:5-16:13: AAPT: error: resource android:attr/colorError not found.

/Users/me/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.0.2.aar/a1a4a045a3ea2f70ae16170c81e2001d/res/values-v26/values-v26.xml:17:5-93: AAPT: error: style attribute 'android:attr/keyboardNavigationCluster' not found.

/Users/me/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.0.2.aar/a1a4a045a3ea2f70ae16170c81e2001d/res/values/values.xml:252:5-69: AAPT: error: resource android:attr/fontStyle not found.

/Users/me/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.0.2.aar/a1a4a045a3ea2f70ae16170c81e2001d/res/values/values.xml:252:5-69: AAPT: error: resource android:attr/font not found.

/Users/me/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.0.2.aar/a1a4a045a3ea2f70ae16170c81e2001d/res/values/values.xml:252:5-69: AAPT: error: resource android:attr/fontWeight not found.

error: failed linking references.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugResources'.
> Failed to process resources, see aapt output above for details.

总的侧面混淆-Facebook在RN设置指南中告诉您目标SDK 23或6.0,但是react native fbsdk的node_modules文件夹中的目标SDK更高,因此给了我警告

记不起我是从哪里学来的,但是如果您觉得鲁莽,可以通过添加:

subprojects {
    afterEvaluate {project ->
    // force libs to use recent buildtools
        if (project.hasProperty("android")) {
            android {
                compileSdkVersion = 27  // change to match your desired version
                buildToolsVersion = "27.0.3" // ....
            }
        }
    }
}
到您的根
android/build.gradle
。在react native git升级之后,到目前为止还没有让我失望。ymmv

build.gradle--内部项目级-->所有项目添加子项目

allprojects {
    repositories {
        mavenLocal()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url("$rootDir/../node_modules/react-native/android")
        }
        maven {
            // Android JSC is installed from npm
            url("$rootDir/../node_modules/jsc-android/dist")

        }


        google()
        jcenter()
    }

       //Add subprojects

    subprojects {
        afterEvaluate {
            project ->
                if (project.hasProperty("android")) {
                    android {
                        compileSdkVersion = 28
                        buildToolsVersion = "28.0.3"
                    }
                }
        }
    }  

}

我对android v26.1.0也有同样的问题,你节省了我的时间!谢谢你,你救了我一天。谢谢
allprojects {
    repositories {
        mavenLocal()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url("$rootDir/../node_modules/react-native/android")
        }
        maven {
            // Android JSC is installed from npm
            url("$rootDir/../node_modules/jsc-android/dist")

        }


        google()
        jcenter()
    }

       //Add subprojects

    subprojects {
        afterEvaluate {
            project ->
                if (project.hasProperty("android")) {
                    android {
                        compileSdkVersion = 28
                        buildToolsVersion = "28.0.3"
                    }
                }
        }
    }