Publish libgdx game to Google Play - java

I just finished up publishing an app to the Google Play store, but when I downloaded it from the store on another phone, it didn't run at all. I set up my libgdx app project based off of this website:
http://obviam.net/index.php/getting-started-in-android-game-development-with-libgdx-create-a-working-prototype-in-a-day-tutorial-part-1/comment-page-2/
which basically had me type all my game code in a Java Project, then launch that from an Android Application Project.
Here is my code for the Android Application Project. Any ideas why this wouldn't launch from the Google Play Store? I'm guessing because the APK does not include the Java Project code, but how do I make it include that?
package ball.activity;
import greenball.activity.GreenBall;
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.backends.android.AndroidApplication;
import activity.ball.greenball_android.R;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.view.Menu;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.Toast;
public class GreenBallActivity extends AndroidApplication implements ApplicationListener {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_green_ball);
AndroidApplicationConfiguration cfg = new AndroidApplicationConfiguration();
cfg.useGL20 = false;
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
initialize(new GreenBall(), cfg);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.green_ball, menu);
return true;
}
#Override
public void create() {
// TODO Auto-generated method stub
}
#Override
public void resize(int width, int height) {
// TODO Auto-generated method stub
}
#Override
public void render() {
// TODO Auto-generated method stub
}
#Override
public void pause() {
// TODO Auto-generated method stub
}
#Override
public void resume() {
// TODO Auto-generated method stub
}
#Override
public void dispose() {
// TODO Auto-generated method stub
}
}

It sounds like there may be a problem with how your app is signed. It would have worked on your test device with just a debug key, but not on any other device. Android requires all apps to be signed before it will install them.

Related

Why isn't my Logcat displaying any log?

Main.java
Package com.first.service;
import android.support.v7.app.ActionBarActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
public class Main extends ActionBarActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Intent i = new Intent(this,Myservice.class);
startService(i);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
MyService.java
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.util.Log;
import android.widget.TextView;
public class Myservice extends Service{
public Myservice(){
}
#Override
public IBinder onBind(Intent intent) {
// TODO Auto-generated method stub
return null;
}
#Override
public void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
}
#Override
public int onStartCommand(Intent intent, int flags, int startId) {
// TODO Auto-generated method stub
Log.i(TAG, "Service Started");
return Service.START_STICKY;
}
}
I am new to android services and I want to create a new Service application, but logcat isn't displaying anything.
Please help me and suggest me, if there is anything wrong with the code.
I am new to StackOverflow.
See the image to have clear idea:
According to this:
Support for the Android Developer Tools (ADT) in Eclipse has ended. You should migrate your app development projects to Android Studio as soon as possible.

android pdf viewer library not working

i tried using the android pdf library. Downloaded from https://github.com/jblough/Android-Pdf-Viewer-Library .
Now when i open the pdf it is stuck .. saying pdf page is loading. ut nothing happens.
Here is what i am trying to do .
I have created a class file called qbchem.java and second.java
i have loaded the pdf file in my asset folder. I dont want any one to access these pdf files and that is why i have kept them in my asset folder.
qbchem.java
#
package com.sp.wisdomedutech11;
import java.io.File;
import android.app.Activity;
import android.app.ActionBar;
import android.app.Fragment;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;
import android.os.Build;
import net.sf.andpdf.pdfviewer.PdfViewerActivity;
public class qbchem extends Activity {
ListView qbchemlv;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.qbchem);
qbchemlv = (ListView) findViewById(R.id.qbchemlv1);
String[] values = new String[] { "Chap-1 Basic Concepts",
"Chap-2 Atomic Structure",
"Chap-3 Chemical Bonding",
"Chap-4 Periodic Table"
};
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, android.R.id.text1, values);
qbchemlv.setAdapter(adapter);
qbchemlv.setOnItemClickListener(new OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
// ListView Clicked item index
int itemPosition = position;
// ListView Clicked item value
String itemValue = (String) qbchemlv.getItemAtPosition(position);
if(itemValue.contentEquals("Chap-1 Basic Concepts")){
try {
Intent intent = new Intent(qbchem.this, second.class);
intent.putExtra(PdfViewerActivity.EXTRA_PDFFILENAME, "file:///android_asset/chap_1_basic_concept.pdf");
startActivity(intent);
} catch (Exception e) {
e.printStackTrace();
}
}
}
});
}}
second.java
package com.sp.wisdomedutech11;
import java.io.File;
import android.app.Activity;
import android.app.ActionBar;
import android.app.Fragment;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;
import android.os.Build;
import net.sf.andpdf.pdfviewer.PdfViewerActivity;
public class second extends PdfViewerActivity {
#Override
public int getPreviousPageImageResource() {
// TODO Auto-generated method stub
return R.drawable.left_arrow;
}
#Override
public int getNextPageImageResource() {
// TODO Auto-generated method stub
return R.drawable.right_arrow;
}
#Override
public int getZoomInImageResource() {
// TODO Auto-generated method stub
return R.drawable.zoom_in;
}
#Override
public int getZoomOutImageResource() {
// TODO Auto-generated method stub
return R.drawable.zoom_out;
}
#Override
public int getPdfPasswordLayoutResource() {
// TODO Auto-generated method stub
return R.layout.pdf_file_password;
}
#Override
public int getPdfPageNumberResource() {
// TODO Auto-generated method stub
return R.layout.dialog_pagenumber;
}
#Override
public int getPdfPasswordEditField() {
// TODO Auto-generated method stub
return R.id.etPassword;
}
#Override
public int getPdfPasswordOkButton() {
// TODO Auto-generated method stub
return R.id.btOK;
}
#Override
public int getPdfPasswordExitButton() {
// TODO Auto-generated method stub
return R.id.btExit;
}
#Override
public int getPdfPageNumberEditField() {
// TODO Auto-generated method stub
return R.id.pagenum_edit;
}}
I had had similar issues while trying to get a pdf reader.In your particular case, you cant get the direct location of your pdf from assets. The only thing that(might) work is copying this asset to some other location , and then using the 'file:///' after that.
This might help you copy the file :
Copying a file from withing a apk to the internal storage
see this for copying too :
https://stackoverflow.com/a/19555787/2670775

OnPrimaryClipChangedListener not working

This is my code for implementation of OnPrimaryCLipChangedListener:
public class PrimaryClipChangedListener implements OnPrimaryClipChangedListener {
#Override
public void onPrimaryClipChanged() {
// TODO Auto-generated method stub
// TODO Auto-generated method stub
Log.d("RAJATH", "copyclip reached");
}
}
My service which register the listener:
package com.example.tryservice;
import android.annotation.SuppressLint;
import android.app.Service;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Intent;
import android.content.ClipboardManager.OnPrimaryClipChangedListener;
import android.os.IBinder;
import android.util.Log;
import android.widget.Toast;
#SuppressLint("NewApi")
public class MyService extends Service{
public MyService() {
}
#Override
public int onStartCommand(Intent intent, int flags, int startId) {
// TODO Auto-generated method stub
Log.d("RAJATH", "Service Reached");
ClipboardManager cb = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
cb.addPrimaryClipChangedListener(new PrimaryClipChangedListener());
return 0;
}
#Override
public IBinder onBind(Intent intent) {
// TODO: Return the communication channel to the service.
throw new UnsupportedOperationException("Not yet implemented");
}
}
I have an activity that starts this service. The purpose of this code is to listen to clipboard changes in the background. Where is the mistake?
What exactly doesn't work? There is a bug in Android 4.3 where the system crashes if you listen for OnPrimaryClipChangedListener callbacks.

Android GPS app not working

i have tryed to make my own app and to use google maps. I want it to set the center of the map on my curent gps position, but when i have a gps lock on my phone i will just go to these coordinates (0,0) I dont know where i went wrong. Thanks everybody :D
import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
public class Courses extends MapActivity {
MapView map;
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.courses);
MapView map = (MapView) findViewById (R.id.MapView);
map.setBuiltInZoomControls(true);
map.setSatellite(true);
final MapController control = map.getController();
LocationManager manager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
LocationListener listener = new LocationListener() {
#Override
public void onLocationChanged(Location location) {
// TODO Auto-generated method stub
control.setCenter(new GeoPoint((int)location.getLatitude(),(int)location.getLongitude()));
control.setZoom(19);
}
#Override
public void onProviderDisabled(String provider) {
// TODO Auto-generated method stub
}
#Override
public void onProviderEnabled(String provider) {
// TODO Auto-generated method stub
}
#Override
public void onStatusChanged(String provider, int status, Bundle extras) {
// TODO Auto-generated method stub
}
};
manager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, listener);
}
#Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
`
The first issue I see here is, that location.getLatitude() and location.getLongitude() return float, which have to be multiplied with 1E6 and then casted as an int to be acceptible for GeoPoint. This also explains why you have coordinates of approximately 0,0
I would suggest replacing your control.setCenter(new GeoPoint((int)location.getLatitude(),(int)location.getLongitude())); with control.setCenter(new GeoPoint((int)(location.getLatitude() * 1E6),(int)(location.getLongitude() * 1E6)));
Try that, it should work then.

how to link the class shown below with main activity

here is the code of the class which i created which extends MainActivity and how can i call this from MainActivity?
I'm trying to figure out where I went wrong on referencing my surface view class, not my view. I only did the view as an example. Here is my main class:
import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.view.View.OnTouchListener;
public class SurfaceViewExample extends Activity implements OnTouchListener{
OurView v;
Bitmap ball;
float x,y;
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
v=new OurView(this);
v.setOnTouchListener(this);
ball=BitmapFactory.decodeResource(getResources(),R.drawable.tennis_ball);
x = y = 0;
setContentView(v);
}
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
v.resume();
}
public class OurView extends SurfaceView implements Runnable{
Thread t;
SurfaceHolder holder;
boolean isItOk=false;
public OurView(Context context) {
super(context);
// TODO Auto-generated constructor stub
holder=getHolder();
}
public void run() {
// TODO Auto-generated method stub
while( isItOk ==true)
{
//drawing
if(holder.getSurface().isValid()) {
continue;
}
Canvas c=holder.lockCanvas();
c.drawARGB(255,150,150,10);
c.drawBitmap(ball, x+(ball.getWidth()/4), y+(ball.getHeight()), null);
holder.unlockCanvasAndPost(c);
}
}
public void pause()
{
isItOk=false;
while(true) {
try {
t.join();
}catch(InterruptedException e) {
e.printStackTrace();
}
break;
}
}
public void resume()
{
isItOk=true;
t=new Thread(this);
t.start();
}
}
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
return false;
}
}
The much i got is that you want to go SurfaceViewExample from your main activity for that you need to use intent on button click like
Intent i = new Intent(this, SurfaceViewExample.class);
startActivity(i) ;
and you have to add a permission in menifest to got to that activity like
<activity android:enabled="true" android:name="SurfaceViewExample" />
and you can see these links also
Calling one Activity from another in Android
http://developer.android.com/reference/android/content/Intent.html

Categories