2015-07-12 89 views
0

虽然我试图运行或调试代码解析符号R,它显示了无差错不能解析符号R.不能在Android Studio中1.2.2的Windows 8

解决方案我都试过了,

  • 清洁工程
  • 同步项目,gradle这个文件
  • 的Invalidate缓存/重启..
  • 重启机器人工作室和笔记本
  • Android-sdk构建工具22

我已经发布了以下不同文件的代码。希望任何人都能找到解决方案。

activity_login_with_fb.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:paddingLeft="@dimen/activity_horizontal_margin" 
android:paddingRight="@dimen/activity_horizontal_margin" 
android:paddingTop="@dimen/activity_vertical_margin" 
android:paddingBottom="@dimen/activity_vertical_margin" 
tools:context="com.example.xyz.phase1.loginWithFb"> 

<com.facebook.login.widget.LoginButton 
    android:id="@+id/login_button" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_gravity="center_horizontal" 
    android:layout_marginTop="30dp" 
    android:layout_marginBottom="30dp" /> 

AndroidMainfest.xml

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
package="com.example.xyz.phase1" > 
<uses-permission android:name="android.permission.INTERNET" /> 

<application 
    android:allowBackup="true" 
    android:icon="@mipmap/ic_launcher" 
    android:label="@string/app_name" 
    android:theme="@style/AppTheme" > 
    <activity 
     android:name=".openingActivity" 
     android:label="@string/app_name" > 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 

      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 
    <activity 
     android:name=".loginWithFb" 
     android:label="@string/title_activity_login_with_fb" > 
    </activity> 

    <meta-data android:name="com.facebook.sdk.ApplicationId" 
    android:value="@string/facebook_app_id"/> 


    <activity android:name="com.facebook.FacebookActivity" 
     android:configChanges= 
      "keyboard|keyboardHidden|screenLayout|screenSize|orientation" 
     android:theme="@android:style/Theme.Translucent.NoTitleBar" 
     android:label="@string/app_name" /> 
    </application> 

</manifest> 

的build.gradle

apply plugin: 'com.android.application' 

android { 
compileSdkVersion 22 
buildToolsVersion "22.0.1" 

defaultConfig { 
    applicationId "com.example.xyz.phase1" 
    minSdkVersion 18 
    targetSdkVersion 22 
    versionCode 1 
    versionName "1.0" 
} 
buildTypes { 
    release { 
     minifyEnabled false 
     proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
    } 
    } 
} 

dependencies { 
    compile fileTree(include: ['*.jar'], dir: 'libs') 
    compile 'com.android.support:appcompat-v7:22.+' 
    compile 'com.android.support:support-v4:22.0.0' 
    compile 'com.facebook.android:facebook-android-sdk:4.1.0' 
    compile project(':facebook') 
} 

loginWithfb.java

public class loginWithFb extends FragmentActivity 
     { 
      CallbackManager callbackManager; 
      AccessTokenTracker accessTokenTracker; 
      AccessToken accessToken; 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_login_with_fb); 
    FacebookSdk.sdkInitialize(this.getApplicationContext()); 
    callbackManager = CallbackManager.Factory.create(); 

    accessTokenTracker = new AccessTokenTracker() { 
     @Override 
     protected void onCurrentAccessTokenChanged(
       AccessToken oldAccessToken, 
       AccessToken currentAccessToken) { 
      // Set the access token using 
      // currentAccessToken when it's loaded or set. 
     } 
    }; 
    // If the access token is available already assign it. 
    accessToken = AccessToken.getCurrentAccessToken(); 
} 
@Override 
public View onCreateView(
     LayoutInflater inflater, 
     ViewGroup container, 
     Bundle savedInstanceState) { 
View view = inflater.inflate(R.layout.activity_login_with_fb, container, 
false); 

LoginButton loginButton=(LoginButton)view.findViewById(R.id.login_button); 
    loginButton.setReadPermissions("user_friends"); 

    // Callback registration 
loginButton.registerCallback(callbackManager, 
new FacebookCallback<LoginResult>() { 
     @Override 
     public void onSuccess(LoginResult loginResult) { 

     } 

     @Override 
     public void onCancel() { 

     } 

     @Override 
     public void onError(FacebookException e) { 

     } 
     }); 
     return view; 
     } 
    } 

回答

-1

我找到了解决方法(在我的情况)。我的问题是,项目的路径很长 - 一些文件夹路径超过255个字符(我认为这只是90年代后期的一个问题)。在我将项目移动到另一条路径(一条短路径)后,所有内容都编译完成

相关问题