2017-05-17 127 views
-3

出錯:';'預計&錯誤:執行失敗的任務':android:compileDebugJava'。 >編譯失敗錯誤:';'預計&錯誤:執行失敗的任務':android:compileDebugJava'。 >彙編失敗

我知道「;」缺少這裏

import com.doragames.adventure.android.R 

但是當我添加它我有其他類似錯誤

Error:(181, 39) error: cannot find symbol variable leaderboard_high_scores 
Error:(191, 39) error: cannot find symbol variable leaderboard_high_scores 
Error:(238, 34) error: cannot find symbol variable achievement_getting_started 
Error:(243, 34) error: cannot find symbol variable achievement_like_a_rover 
Error:(248, 34) error: cannot find symbol variable achievement_spirit 
Error:(253, 34) error: cannot find symbol variable achievement_curiosity 
Error:(258, 34) error: cannot find symbol variable achievement_5k_club 
Error:(263, 34) error: cannot find symbol variable achievement_10k_club 
Error:(268, 34) error: cannot find symbol variable achievement_25k_club 
Error:(273, 34) error: cannot find symbol variable achievement_50k_club 
Error:(278, 34) error: cannot find symbol variable achievement_10_jump_street 
Error:(283, 34) error: cannot find symbol variable achievement_100_jump_street 
Error:(288, 34) error: cannot find symbol variable achievement_500_jump_street 
Error:(292, 34) error: cannot find symbol variable ad_unit_id 
Error:Execution failed for task ':android:compileDebugJava'. 

這是我androidLauncher.java

package com.doragames.adventure.android; 

import android.content.Intent; 
import android.os.Bundle; 
import android.view.View; 
import android.view.Window; 
import android.view.WindowManager; 
import android.widget.RelativeLayout; 
import com.badlogic.gdx.backends.android.AndroidApplication; 
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration; 
import com.doragames.adventure.MartianRun; 
import com.doragames.adventure.utils.Constants; 
import com.doragames.adventure.utils.GameEventListener; 
import com.doragames.adventure.utils.GameManager; 
import com.google.android.gms.ads.AdRequest; 
import com.google.android.gms.ads.AdSize; 
import com.google.android.gms.ads.AdView; 
import com.google.android.gms.analytics.GoogleAnalytics; 
import com.google.android.gms.games.Games; 
import com.google.games.basegameutils.GameHelper; 
import com.doragames.adventure.android.R 


public class AndroidLauncher extends AndroidApplication implements GameHelper.GameHelperListener, 
    GameEventListener { 

private static String SAVED_LEADERBOARD_REQUESTED = "SAVED_LEADERBOARD_REQUESTED"; 
private static String SAVED_ACHIEVEMENTS_REQUESTED = "SAVED_ACHIEVEMENTS_REQUESTED"; 

private GameHelper gameHelper; 

private AdView mAdView; 
private boolean mLeaderboardRequested; 
private boolean mAchievementsRequested; 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 

    // Create the layout 
    RelativeLayout layout = new RelativeLayout(this); 

    requestWindowFeature(Window.FEATURE_NO_TITLE); 
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
      WindowManager.LayoutParams.FLAG_FULLSCREEN); 
    getWindow().clearFlags(
      WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); 

    AndroidApplicationConfiguration config = new AndroidApplicationConfiguration(); 

    // Game view 
    View gameView = initializeForView(new MartianRun(this), config); 
    layout.addView(gameView); 


    mAdView = createAdView(); 
    mAdView.loadAd(createAdRequest()); 

    layout.addView(mAdView, getAdParams()); 

    setContentView(layout); 

    gameHelper = new GameHelper(this, GameHelper.CLIENT_GAMES); 
    gameHelper.setup(this); 
    gameHelper.setMaxAutoSignInAttempts(0); 
} 

@Override 
protected void onStart() { 
    super.onStart(); 
    gameHelper.onStart(this); 
    GoogleAnalytics.getInstance(this).reportActivityStart(this); 
} 

@Override 
protected void onStop() { 
    super.onStop(); 
    gameHelper.onStop(); 
    GoogleAnalytics.getInstance(this).reportActivityStop(this); 
} 

@Override 
protected void onActivityResult(int requestCode, int resultCode, Intent data) { 
    super.onActivityResult(requestCode, resultCode, data); 
    gameHelper.onActivityResult(requestCode, resultCode, data); 
} 

@Override 
protected void onSaveInstanceState(Bundle outState) { 
    super.onSaveInstanceState(outState); 
    outState.putBoolean(SAVED_LEADERBOARD_REQUESTED, mLeaderboardRequested); 
    outState.putBoolean(SAVED_ACHIEVEMENTS_REQUESTED, mAchievementsRequested); 
} 

@Override 
protected void onRestoreInstanceState(Bundle savedInstanceState) { 
    super.onRestoreInstanceState(savedInstanceState); 
    mLeaderboardRequested = savedInstanceState.getBoolean(SAVED_LEADERBOARD_REQUESTED, false); 
    mAchievementsRequested = savedInstanceState.getBoolean(SAVED_ACHIEVEMENTS_REQUESTED, false); 
} 

private AdRequest createAdRequest() { 
    return new AdRequest.Builder() 
      .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) 
      .build(); 
} 

private AdView createAdView() { 
    AdView adView = new AdView(this); 

    adView.setAdSize(AdSize.SMART_BANNER); 
    adView.setAdUnitId(getAdMobUnitId()); 

    return adView; 
} 

private RelativeLayout.LayoutParams getAdParams() { 
    RelativeLayout.LayoutParams adParams = new RelativeLayout.LayoutParams(
      RelativeLayout.LayoutParams.MATCH_PARENT, 
      RelativeLayout.LayoutParams.WRAP_CONTENT); 

    adParams.addRule(RelativeLayout.ALIGN_PARENT_TOP); 

    return adParams; 
} 

@Override 
public void onSignInFailed() { 
    // handle sign-in failure (e.g. show Sign In button) 
    mLeaderboardRequested = false; 
    mAchievementsRequested = false; 
} 

@Override 
public void onSignInSucceeded() { 
    // handle sign-in success 
    if (GameManager.getInstance().hasSavedMaxScore()) { 
     GameManager.getInstance().submitSavedMaxScore(); 
    } 

    if (mLeaderboardRequested) { 
     displayLeaderboard(); 
     mLeaderboardRequested = false; 
    } 

    if (mAchievementsRequested) { 
     displayAchievements(); 
     mAchievementsRequested = false; 
    } 
} 

@Override 
public void displayAd() { 
    mAdView.setVisibility(View.VISIBLE); 
} 

@Override 
public void hideAd() { 
    mAdView.setVisibility(View.GONE); 
} 

@Override 
public void submitScore(int score) { 
    if (gameHelper.isSignedIn()) { 
     Games.Leaderboards.submitScore(gameHelper.getApiClient(), 
       getString(R.string.leaderboard_high_scores), score); 
    } else { 
     GameManager.getInstance().saveScore(score); 
    } 
} 

@Override 
public void displayLeaderboard() { 
    if (gameHelper.isSignedIn()) { 
     startActivityForResult(Games.Leaderboards.getLeaderboardIntent(gameHelper.getApiClient(), 
       getString(R.string.leaderboard_high_scores)), 24); 
    } else { 
     gameHelper.beginUserInitiatedSignIn(); 
     mLeaderboardRequested = true; 
    } 
} 

@Override 
public void displayAchievements() { 
    if (gameHelper.isSignedIn()) { 
     startActivityForResult(
       Games.Achievements.getAchievementsIntent(gameHelper.getApiClient()), 25); 
    } else { 
     gameHelper.beginUserInitiatedSignIn(); 
     mAchievementsRequested = true; 
    } 
} 

@Override 
public void share() { 
    String url = String.format("http://play.google.com/store/apps/details?id=%s", 
      BuildConfig.APPLICATION_ID); 
    String message = String.format(Constants.SHARE_MESSAGE_PREFIX, url); 
    Intent share = new Intent(Intent.ACTION_SEND); 
    share.setType("text/plain"); 
    share.putExtra(Intent.EXTRA_TEXT, message); 
    startActivity(Intent.createChooser(share, Constants.SHARE_TITLE)); 
} 

@Override 
public void unlockAchievement(String id) { 
    if (gameHelper.isSignedIn()) { 
     Games.Achievements.unlock(gameHelper.getApiClient(), id); 
     GameManager.getInstance().setAchievementUnlocked(id); 
    } 
} 

@Override 
public void incrementAchievement(String id, int steps) { 
    if (gameHelper.isSignedIn()) { 
     Games.Achievements.increment(gameHelper.getApiClient(), id, steps); 
     GameManager.getInstance().incrementAchievementCount(id, steps); 
    } 
} 

@Override 
public String getGettingStartedAchievementId() { 
    return getString(R.string.achievement_getting_started); 
} 

@Override 
public String getLikeARoverAchievementId() { 
    return getString(R.string.achievement_like_a_rover); 
} 

@Override 
public String getSpiritAchievementId() { 
    return getString(R.string.achievement_spirit); 
} 

@Override 
public String getCuriosityAchievementId() { 
    return getString(R.string.achievement_curiosity); 
} 

@Override 
public String get5kClubAchievementId() { 
    return getString(R.string.achievement_5k_club); 
} 

@Override 
public String get10kClubAchievementId() { 
    return getString(R.string.achievement_10k_club); 
} 

@Override 
public String get25kClubAchievementId() { 
    return getString(R.string.achievement_25k_club); 
} 

@Override 
public String get50kClubAchievementId() { 
    return getString(R.string.achievement_50k_club); 
} 

@Override 
public String get10JumpStreetAchievementId() { 
    return getString(R.string.achievement_10_jump_street); 
} 

@Override 
public String get100JumpStreetAchievementId() { 
    return getString(R.string.achievement_100_jump_street); 
} 

@Override 
public String get500JumpStreetAchievementId() { 
    return getString(R.string.achievement_500_jump_street); 
} 

private String getAdMobUnitId() { 
    return getString(R.string.ad_unit_id); 
} 

} 
+0

添加';'肯定是正確的,你將它添加到了那裏已經只是沒有顯示,因爲語法檢查器停在了第一次出現後收到錯誤缺少分號(不確定這是否完全正確,但我認爲它至少是一個指針)。錯誤消息表示「R.string」的所有變量(例如'R.string.leaderboard_high_scores')未定義。 – TuringTux

+0

和R.string錯誤的解決方法是什麼plz –

+0

對不起,@ houd-bl,我對Android編程沒有太多的知識。我會嘗試用'R'類專門搜索probelms。你有看看[這個問題](https://stackoverflow.com/questions/6804053/understand-the-r-class-in-android)或[this one](https://stackoverflow.com/questions/4953077/Android的東西,是-R-爲什麼 - 是 - 它那麼神祕的)? – TuringTux

回答

0

編譯錯誤首次從防止[R正確生成。重建項目並確保;在那裏,並且該類將被生成並且應該再次運行。

+0

這不是工作兄弟 –

0

清潔工程和重建它

+0

這不是工作兄弟 –

相關問題