我在Android Studio下使用LibGDX和RoboPods来编译iOS。从RoboVM迁移到mobidevelop,我现在面临一些问题。主要的一个是我不能登录谷歌。
[GPGManager signIn:didSignInForUser:withError:]:[main] FAILED LOGGING INTO GOOGLE PLUS GAMES Error Domain=com.google.GIDSignIn Code=-2 "keychain error" UserInfo={NSLocalizedDescription=keychain error}
我知道您可以在XCode中更改KeyChain参数,但由于这是一个LibGDX游戏,我不使用XCode。
githiub上的一个示例项目说明了这个问题:https://github.com/julienvillegas/libgdx-google-play-game-services-integration-sample
我的代码如下:
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.backends.iosrobovm.IOSApplication;
import com.badlogic.gdx.backends.iosrobovm.IOSApplicationConfiguration;
import com.julienvillegas.CrosswordParty.CrosswordParty;
import com.julienvillegas.CrosswordParty.NearbyGPGSPlayers;
import com.julienvillegas.GameWorld.CrosswordCommon.CrosswordGiftCreate.GiftGridCombinations;
import com.julienvillegas.GameWorld.Global;
import com.julienvillegas.actionResolver.ActionResolver;
import org.robovm.apple.foundation.Foundation;
import org.robovm.apple.foundation.NSArray;
import org.robovm.apple.foundation.NSAutoreleasePool;
import org.robovm.apple.foundation.NSError;
import org.robovm.apple.foundation.NSObject;
import org.robovm.apple.foundation.NSString;
import org.robovm.apple.foundation.NSURL;
import org.robovm.apple.uikit.UIActivityViewController;
import org.robovm.apple.uikit.UIApplication;
import org.robovm.apple.uikit.UIApplicationLaunchOptions;
import org.robovm.apple.uikit.UIViewController;
import org.robovm.objc.block.VoidBlock4;
import org.robovm.pods.google.games.GPGAchievement;
import org.robovm.pods.google.games.GPGAchievementUnlockCallback;
import org.robovm.pods.google.games.GPGLauncherController;
import org.robovm.pods.google.games.GPGLeaderboard;
import org.robovm.pods.google.games.GPGLeaderboardLoadScoresCallback;
import org.robovm.pods.google.games.GPGLeaderboardTimeScope;
import org.robovm.pods.google.games.GPGManager;
import org.robovm.pods.google.games.GPGPlayer;
import org.robovm.pods.google.games.GPGPlayerGetCallback;
import org.robovm.pods.google.games.GPGScore;
import org.robovm.pods.google.games.GPGScoreReport;
import org.robovm.pods.google.games.GPGScoreReportCallback;
import org.robovm.pods.google.games.GPGStatusDelegate;
import org.robovm.pods.google.mobileads.GADInterstitial;
import org.robovm.pods.google.mobileads.GADInterstitialDelegateAdapter;
import org.robovm.pods.google.mobileads.GADMobileAds;
import org.robovm.pods.google.mobileads.GADRequest;
import org.robovm.pods.google.mobileads.GADRequestError;
import org.robovm.pods.google.signin.GIDSignIn;
import org.robovm.pods.google.signin.GIDSignInUIDelegateAdapter;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;
public class IOSLauncher extends IOSApplication.Delegate implements ActionResolver,GPGStatusDelegate {
private static NearbyGPGSPlayers nearbyGPGSPlayers;
public static final String CLIENT_ID_FREE = "xxxx.yy.z1";
public static final String CLIENT_ID_NOADS = "xxxx.yy.z2";
public static String CLIENT_ID = "";
private IOSApplication app;
static public GADInterstitial interstitial;
static private GPGPlayer gpgplayer;
private Screen postAdScreen;
GADRequest request;
IOSApplication local_app;
@Override
protected IOSApplication createApplication() {
System.out.println("IOSLauncher:createApplication:start");
if(Global.FREE_EDITION){
CLIENT_ID = CLIENT_ID_FREE;
}
else{
CLIENT_ID = CLIENT_ID_NOADS;
}
System.out.println("IOSLauncher:createApplication:Step1");
IOSApplicationConfiguration config = new IOSApplicationConfiguration();
System.out.println("IOSLauncher:createApplication:Step2");
app = new IOSApplication(CrosswordParty.getInstance(this), config);
local_app = app;
System.out.println("IOSLauncher:createApplication:configuring ads");
GADMobileAds.disableSDKCrashReporting();
createRequest();
interstitial = createAndLoadInterstitial();
System.out.println("IOSLauncher:createApplication:end");
GIDSignIn.getSharedInstance().setUiDelegate(new GIDSignInUIDelegateAdapter() {
private UIViewController libgdxViewController;
@Override
public void willDispatch(GIDSignIn signIn, NSError error) {
Foundation.log("willDispatch()");
}
@Override
public void presentViewController(GIDSignIn signIn, UIViewController viewController) {
Foundation.log("presentViewController()");
libgdxViewController = UIApplication.getSharedApplication().getKeyWindow().getRootViewController();
// .presentViewController(viewController, true, null);
UIApplication.getSharedApplication().getKeyWindow().setRootViewController(viewController);
}
@Override
public void dismissViewController(GIDSignIn signIn, UIViewController viewController) {
Foundation.log("dismissViewController()");
//viewController.dismissViewController(true, null);
UIApplication.getSharedApplication().getKeyWindow().setRootViewController(libgdxViewController);
}
});
return app;
}
public static void main(String[] argv) {
System.out.println("IOSLauncher:main:start");
NSAutoreleasePool pool = new NSAutoreleasePool();
UIApplication.main(argv, null, IOSLauncher.class);
pool.close();
System.out.println("IOSLauncher:main:end");
}
@Override
public boolean didFinishLaunching(UIApplication application, UIApplicationLaunchOptions launchOptions) {
super.didFinishLaunching(application, launchOptions);
Foundation.log("IOSLauncher didFinishLaunching()");
// GIDSignIn.getSharedInstance().setAllowsSignInWithWebView(true);
GPGManager.getSharedInstance().signIn(CLIENT_ID, true);
return true;
}
private GADInterstitial createAndLoadInterstitial() {
System.out.println("IOSLauncher:createAndLoadInterstitial:here");
if(Global.DEV_MODE){
//interstitial = new GADInterstitial(GGLContextMobileAds.getSharedInstance().getAdUnitIDForInterstitialTest());
interstitial = new GADInterstitial("xxxxx");
}
else{
//interstitial = new GADInterstitial(GGLContextMobileAds.getSharedInstance().getConfiguration().getInterstitialAdUnitID());
interstitial = new GADInterstitial("yyyyy");
}
interstitial.setDelegate(new GADInterstitialDelegateAdapter() {
@Override
public void didReceiveAd(GADInterstitial ad) {
System.out.println("IOSLauncher:createAndLoadInterstitial:received ad.");
}
@Override
public void didDismissScreen(GADInterstitial ad) {
System.out.println("IOSLauncher:createAndLoadInterstitial:closed ad");
CrosswordParty.getInstance().setScreen(postAdScreen);
}
@Override
public void didFailToReceiveAd(GADInterstitial ad, GADRequestError error) {
System.out.println("IOSLauncher:createAndLoadInterstitial:error" + error.description());
System.out.println("IOSLauncher:createAndLoadInterstitial:error" + error.getErrorCode());
}
});
interstitial.loadRequest(request);
return interstitial;
}
private GADRequest createRequest() {
System.out.println("IOSLauncher:createRequest:here");
request = new GADRequest();
// To test on your devices, add their UDIDs here:
request.setTestDevices(Arrays.asList(GADRequest.getSimulatorID()));
return request;
}
@Override
public void showOrLoadInterstital(Screen aScreen) {
System.out.println("IOSLauncher:showOrLoadInterstital:here");
if(postAdScreen == null){
postAdScreen = CrosswordParty.crosswordScreen;
}
if (postAdScreen.getClass() == CrosswordParty.crosswordScreen.getClass()) {
postAdScreen = CrosswordParty.scrableScreen;
} else {
postAdScreen = CrosswordParty.crosswordScreen;
}
if (interstitial.isReady()) {
System.out.println("IOSLauncher:showOrLoadInterstital:showing add!");
UIViewController viewController = UIApplication.getSharedApplication().getKeyWindow().getRootViewController();
interstitial.present(viewController);
//interstitial.present(app.getUIViewController());
} else {
System.out.println("IOSLauncher:showOrLoadInterstital:Interstitial not ready!");
CrosswordParty.getInstance().setScreen(postAdScreen);
}
createAndLoadInterstitial();
}
@Override
public boolean getSignedInGPGS() {
System.out.println("IOSLauncher:getSignedInGPGS:is Signed in? " + GPGManager.getSharedInstance().isSignedIn());
return GPGManager.getSharedInstance().isSignedIn();
}
@Override
public void loginGPGSSilently() {
System.out.println("IOSLauncher:loginGPGSSilently:Start");
if(!getSignedInGPGS()){
try {
GPGManager.getSharedInstance().signIn(CLIENT_ID, true);
GPGManager.getSharedInstance().setStatusDelegate(this);
} catch (final Exception ex) {
}
};
}
@Override
public void loginGPGS() {
System.out.println("IOSLauncher:loginGPGS:Start");
if(!getSignedInGPGS()){
try {
GPGManager.getSharedInstance().signIn(CLIENT_ID, false);
GPGManager.getSharedInstance().setStatusDelegate(this);
} catch (final Exception ex) {
}
};
}
@Override
public String getGPGSName() {
if (GPGManager.getSharedInstance().isSignedIn()) {
return gpgplayer.getDisplayName();
} else{
loginGPGS();
return null;
}
}
@Override
public void submitScoreGPGS(int score) {
System.out.println("IOSLauncher:submitScoreGPGS:here");
GPGScore gpgScore = new GPGScore(Global.LEADERBOARD_SCORE);
gpgScore.setValue(score);
GPGScoreReportCallback gpgscoreReportCallback = new GPGScoreReportCallback(){
@Override
public void done(GPGScoreReport report, NSError error) {
if (error != null) {
System.out.println("IOSLauncher:submitScoreGPGS:Error");
}
else{
System.out.println("IOSLauncher:submitScoreGPGS:Done");
}
}
};
gpgScore.submitScore(gpgscoreReportCallback);
}
@Override
public void submitStarChallengeScoreGPGS(int starChallenge) {
System.out.println("IOSLauncher:submitStarChallengeScoreGPGS:here");
GPGScore gpgScore = new GPGScore(Global.LEADERBOARD_STARSTREAK);
gpgScore.setValue(starChallenge);
GPGScoreReportCallback gpgscoreReportCallback = new GPGScoreReportCallback(){
@Override
public void done(GPGScoreReport report, NSError error) {
if (error != null) {
System.out.println("IOSLauncher:submitScoreGPGS:Error");
}
else{
System.out.println("IOSLauncher:submitScoreGPGS:Done");
}
}
};
gpgScore.submitScore(gpgscoreReportCallback);
}
@Override
public void submitCrosswordChallengeScoreGPGS(int crosswordChallenge) {
System.out.println("IOSLauncher:submitCrosswordChallengeScoreGPGS:here");
GPGScore gpgScore = new GPGScore(Global.LEADERBOARD_COMBOS);
gpgScore.setValue(crosswordChallenge);
GPGScoreReportCallback gpgscoreReportCallback = new GPGScoreReportCallback(){
@Override
public void done(GPGScoreReport report, NSError error) {
if (error != null) {
System.out.println("IOSLauncher:submitScoreGPGS:Error");
}
else{
System.out.println("IOSLauncher:submitScoreGPGS:Done");
}
}
};
gpgScore.submitScore(gpgscoreReportCallback);
}
@Override
public void unlockAchievementGPGS(String achievementId) {
System.out.println("IOSLauncher:unlockAchievementGPGS:here");
GPGAchievement gpgachievement = new GPGAchievement(achievementId);
GPGAchievementUnlockCallback gpgachievementUnlockCallback = new GPGAchievementUnlockCallback() {
@Override
public void done(boolean newlyUnlocked, NSError error) {
if (error != null) {
System.out.println("IOSLauncher:unlockAchievementGPGS:Error while unlocking!");
} else {
System.out.println("IOSLauncher:unlockAchievementGPGS:unlock succeeded. newlyUnlocked: " + newlyUnlocked);
}
}
};
gpgachievement.unlock(gpgachievementUnlockCallback);
}
@Override
public void getAllLeaderboardsGPGS() {
System.out.println("IOSLauncher:getAllLeaderboardsGPGS:here");
boolean isSignedInFlag = GPGManager.getSharedInstance().isSignedIn();
System.out.println("IOSLauncher:loginGPGS:is signed in?" + isSignedInFlag);
if (GPGManager.getSharedInstance().isSignedIn()) {
GPGLauncherController.getSharedInstance().presentLeaderboardList();
} else {
loginGPGS();
}
}
@Override
public void getLeaderboardScoreGPGS() {
System.out.println("IOSLauncher:getLeaderboardScoreGPGS:here");
if (GPGManager.getSharedInstance().isSignedIn()) {
GPGLauncherController.getSharedInstance().presentLeaderboard(Global.LEADERBOARD_SCORE);
} else{
loginGPGS();
// loginGPGS();
}
}
@Override
public void getLeaderboardStarChallengeGPGS() {
System.out.println("IOSLauncher:getLeaderboardStarChallengeGPGS:here");
if (GPGManager.getSharedInstance().isSignedIn()) {
GPGLauncherController.getSharedInstance().presentLeaderboard(Global.LEADERBOARD_STARSTREAK);
} else{
loginGPGS();
}
}
@Override
public void getLeaderboardCrosswordChallengeGPGS() {
System.out.println("IOSLauncher:getLeaderboardCrosswordChallengeGPGS:here");
if (GPGManager.getSharedInstance().isSignedIn()) {
GPGLauncherController.getSharedInstance().presentLeaderboard(Global.LEADERBOARD_COMBOS);
} else{
loginGPGS();
}
}
@Override
public void getAchievementsGPGS() {
System.out.println("IOSLauncher:getAchievementsGPGS:here");
if (GPGManager.getSharedInstance().isSignedIn()) {
GPGLauncherController.getSharedInstance().presentAchievementList();
} else{
loginGPGS();
}
}
@Override
public void getNearbyPlayers() {
System.out.println("IOSLauncher:getNearbyPlayers:here");
if (GPGManager.getSharedInstance().isSignedIn()) {
GPGLeaderboard gpgleaderboard = GPGLeaderboard.getLeaderboard(Global.LEADERBOARD_SCORE);
gpgleaderboard.setSocial(true);
gpgleaderboard.setPersonalWindow(true);
gpgleaderboard.setTimeScope(GPGLeaderboardTimeScope.AllTime);
GPGLeaderboardLoadScoresCallback gpgleaderboardLoadScoresCallback = new GPGLeaderboardLoadScoresCallback() {
@Override
public void done(NSArray<GPGScore> scores, NSError error) {
nearbyGPGSPlayers = new NearbyGPGSPlayers(gpgplayer.getPlayerId());
for(int i = 0;i< scores.size();i++){
GPGScore aScore = scores.get(i);
GPGPlayer aScorePlayer = aScore.getPlayer();
System.out.println("IOSLauncher:getNearbyPlayers:Player:" + aScorePlayer.getDisplayName() + "Score:" + aScore.getValue());
nearbyGPGSPlayers.addPlayer(aScorePlayer.getPlayerId(), aScorePlayer.getDisplayName(),aScore.getValue(),aScore.getFormattedRank());
}
nearbyGPGSPlayers.notify_Player();
}
};
gpgleaderboard.loadScores(gpgleaderboardLoadScoresCallback);
}
else{
loginGPGS();
}
}
@Override
public void sendGiftGrid(String textToShare, String subject, String URL) {
NSArray<NSObject> items = new NSArray<>(
new NSString(textToShare),
new NSURL(URL));
UIViewController viewController = UIApplication.getSharedApplication().getKeyWindow().getRootViewController();
UIActivityViewController uiActivityViewController = new UIActivityViewController(items, null);
uiActivityViewController.setCompletionWithItemsHandler(new VoidBlock4<String, Boolean, NSArray<NSObject>, NSError>() {
@Override
public void invoke(String s, Boolean aBoolean, NSArray<NSObject> nsObjects, NSError nsError) {
GiftGridCombinations.getInstance().getSelectedCombination().setShared(true);
}
});
/* ((IOSApplication) Gdx.app).getUIViewController().presentViewController(uiActivityViewController, true, null);
*/
viewController.presentViewController(uiActivityViewController, true, null);
}
@Override
public void didFinishGamesSignIn(NSError error) {
System.out.println("IOSLauncher:didFinishGamesSignIn:here");
GPGPlayerGetCallback gpgplayerGetCallback = new GPGPlayerGetCallback(){
@Override
public void done(GPGPlayer player, NSError error) {
gpgplayer = player;
System.out.println("IOSLauncher:didFinishGamesSignIn:name:"+gpgplayer.getDisplayName()+":id:"+gpgplayer.getPlayerId());
getNearbyPlayers();
}
};
GPGPlayer.getLocalPlayer(gpgplayerGetCallback);
}
@Override
public void didFinishGamesSignOut(NSError error) {
System.out.println("IOSLauncher:didFinishGamesSignOut:here");
}
@Override
public void didFinishGoogleAuth(NSError error) {
System.out.println("IOSLauncher:didFinishGoogleAuth:here");
}
@Override
public boolean shouldReauthenticate(NSError error) {
System.out.println("IOSLauncher:shouldReauthenticate:here");
return false;
}
@Override
public void willReauthenticate(NSError error) {
System.out.println("IOSLauncher:willReauthenticate:here");
}
/*
@Override
public void finished(GTMOAuth2Authentication auth, NSError error) {
System.out.println("IOSLauncher:finished:here");
}
*/
@Override
public void didDisconnect(NSError error) {
System.out.println("IOSLauncher:didDisconnect:here");
}
/*
@Override
public boolean openURL(UIApplication application, NSURL url, String sourceApplication, NSPropertyList annotation) {
System.out.println("IOSLauncher:openURL:here");
boolean canRespond = GIDSignIn.getSharedInstance().handleURL(url, sourceApplication, annotation);
if (canRespond) {
return true;
} else {
// There might be other things you'd want to do here
return false;
}
}
*/
@Override
public String getDateAsString(Date aDate, String format) {
SimpleDateFormat SimpleDateFormat = new SimpleDateFormat(format) ;
//DateTimeFormat dateFormat = DateTimeFormat.getFormat("yyyyMMddHHmmssS");
TimeZone timeZone = TimeZone.getTimeZone("UTC");
SimpleDateFormat.setTimeZone(timeZone);
Calendar cal = Calendar.getInstance(timeZone);
cal.setTime(aDate);
return SimpleDateFormat.format(cal.getTime()).trim();
}
@Override
public Date getStringAsDate(String aDate, String format) {
SimpleDateFormat SimpleDateFormat = new SimpleDateFormat(format) ;
TimeZone timeZone = TimeZone.getTimeZone("UTC");
SimpleDateFormat.setTimeZone(timeZone);
try {
Date date = SimpleDateFormat.parse(aDate);
return date;
}
catch(Exception e){
return null;
}
}
@Override
public void runInBackground(Runnable toBeRun) {
new Thread(toBeRun).start();
}
}
这是Xcode中的一个问题。只有在使用XCode进行调试时才会出现这种情况,所以如果将手机与XCode断开并启动应用程序,就不会出现错误。可以通过target->功能和启用钥匙链共享来修复。
这个问题应该在Xcode8.2中得到修复。
前面我们讲了 Gradle 在 Android 项目中的配置,我们提到有一个闭包 signingConfigs 是配置 Android 应用签名信息的。那么今天我们就来讲讲如何通过 AndroidStudio 对 APK 进行签名。 1. 新建 keyStore 文件 我们下面一步步带大家,用 AndroidStudio 来配置签名。 首先顶部菜单栏找到 Build 点击他我们会看到 Genera
编者注:RoboVM 项目已经关闭,目前有开源替代产品 BugVM。 RoboVM 编译器可以将 Java 字节码翻译成 ARM 或者 x86 平台上的原生代码,应用可直接在 CPU 上运行,无需其他解释器或者虚拟机。 RoboVM 同时包含一个 Java 到 Objective-C 的桥,可像其他 Java 对象一样来使用 Objective-C 对象。大多数 UIKit 已经支持,而且将会支持
我想做一个应用程序,使用谷歌翻译API。自从我添加了 我的构建中的依赖项。gradle我有个错误: 现在必须显式声明注释处理器。发现编译类路径上的以下依赖项包含注释处理器。请将它们添加到annotationProcessor配置中。-自动值-1.2。jar(com.google.auto.value:auto-value:1.2)或者,设置android。defaultConfig。javaCom
我在一个Android/iOS应用程序中遇到了一个问题:库代码(libgdx?)抛出一个NPE,但不支持在RoboVM中调试。在Android中运行时,它的工作方式与预期一致,并会出现方法。在IOs中运行时,它将到达failed(Throwable t)方法,其中t是。我创建了一个示例应用程序来展示这个问题,也许是我的错,所以下面是代码:
您能帮助在android studio中运行默认java而不是gradle执行吗?谢谢
我正在尝试建立一个简单的“飞鸟”游戏,我需要鸟的图像倾斜,上升时指向上方,反之亦然。然而,当旋转我的图像时,它会在稍微下降或轻触屏幕后部分或完全从屏幕上消失。谁能告诉我怎么解决这个问题吗?