How to change application icon for a libgdx android project - java

I'm trying to change the application icon for a libGDX Project, which I use to develop games. They give a sample ic_launcher.png file to use for setting the app icon, and I'm trying to change it to a different png file. I have specified everything for mdpi, hdpi, xhdpi, xxhdpi, and xxxhdpi, and also an anydpi, but in the AndroidManifest.xml, when I want to change the icon to #drawable/my_launcher, it says that it's an invalid symbol. I have even specified the same lengths and widths as the ic_launcher.png provided. Here is the AndroidManifest.xml file.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.zunkuftedu.zunkuftlife" >
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:isGame="true"
android:appCategory="game"
android:label="#string/app_name"
android:theme="#style/GdxTheme" >
<activity
android:name="org.zunkuftedu.zunkuftlife.AndroidLauncher"
android:label="#string/app_name"
android:screenOrientation="landscape"
android:configChanges="keyboard|keyboardHidden|navigation|orientation|screenSize|screenLayout">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
This is a libGDX project, so it's different from normal Android Studio projects. Any help will be appreciated.

You shouldn't need to change any code. The android\res folder has folders with icons for different resolutions. You can simply overwrite the ic_launcher.png file in each of those folders with your own custom image (make sure you match the sizes of the existing images in each folder). That's how I've done it and it works great.

Related

Error parsing LocalFile: Please ensure that theandroid manifest is a valid XML document and try again

making an App for Android with flutter and VS code with JAVA as main activity in it everything works fine but sudden we come up with the error of invalid XML file of android manifest.
this is the code written in the manifest xml file
i have also try adding this android:usesCleartextTraffic="true" ,
but nothing works
XML
`<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.examp.dp">
<application
android:name="io.flutter.app.FlutterApplication"
android:label="wallyh"
android:icon="#mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="#style/LaunchTheme"
android:config Changes="orientation|keyboard Hidden|keyboard
|screenSize|smallest ScreenSize|locale|layout Direction|
font Scale|screen Layout|density|ui Mode"
android:hardware Accelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="#style/NormalTheme"
/>
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="#drawable/launch_background"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>
`

Android Studio 2.3.3 won't load class file from JAR

I've copied a jar file into my project's libs folder. Usually it will show me all of the files contained therein. For this one JAR file, it won't display the class file embedded inside, but does display a manifest file.
Let's say the jar is custom-unity-activity.jar and the directory structure is com\custom\activity\custom-unity-activity.class. As far as Android Studio gets is "com.custom" and then goes no further. The compiler also can't resolve symbols defined in the class file, so it definitely isn't reading it in.
I know this jar file is valid, because it has been used successfully under a different build environment.
It's really hard to import Unity's project into an existing Android Project. The solution is to do it the other way around instead.
Build the Android Studio project as to jar or .arr plugin then place in your Unity project at: <ProjectName>Assets\Plugins\Android.
If you want to load your Android Studio project activity, you must modify the AndroidManifest.xml to let Unity know that then place it at:<ProjectName>Assets\Plugins\Android.
Below is what the XML should look like. It will specify the activity name to load and will also tell Unity to allow you to use input events from your Android Studio project otherwise, Unity will steal those events. The manifest below assumes that the Android Studio activity name is "MainActivity".
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.casualcoder.plugin" android:installLocation="auto">
<uses-sdk
android:minSdkVersion="19"
android:targetSdkVersion="19" />
<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:anyDensity="true" />
<application android:icon="#drawable/app_icon" android:label="#string/app_name">
<activity android:name=".MainActivity"
android:label="#string/app_name"
android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
<meta-data android:name="android.app.lib_name" android:value="unity" />
<meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.unity3d.player.UnityPlayerNativeActivity"
android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen"
android:screenOrientation="landscape">
<meta-data android:name="android.app.lib_name" android:value="unity" />
<meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true" />
</activity>
android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen"
android:screenOrientation="landscape">
<meta-data android:name="android.app.lib_name" android:value="unity" />
<meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true" />
</activity>
</application>
</manifest>

unable to instantiate activity, ClassNotFoundException

I am developing an android application and after moving around some libraries and adjusting my workspace so that it can sync with github I am now encountering a new error that I have not had in the past. Here is the print out in LogCat.
FATAL EXCEPTION: main
Process: com.exmple.loop, PID:1000
java.lang.RuntimeException: Unable to instantiate activity
ComponentInfo{com.example.loop/com.example.loop.MainActivity}:
java.lang.ClassNotFoundException: Didn't find class "com.example.loop.MainActivity" on
path: DexpathList[[zip file "/data/app/com.example.loop-2.apk"]...
I can supply more if needed. I have checked stackoverflow for solutions and came across some that proved to be unhelpful. Here is the first question I found and here is the second. I tried the helpful solutions for both and nothing seems to work. Similar to the user in the first question, the exception is thrown before any line I write because it is failing to recognize my main activity as a class.
Here is my android manifest.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.loop"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:name="com.example.loop.LoopApplication"
android:icon="#drawable/loop_icon"
android:label="#string/app_name"
android:theme="#style/Theme.Loop" >
<meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" />
<activity
android:name="com.example.loop.MainActivity"
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:theme="#style/AppTheme" android:logo="#drawable/loop_icon" android:name="LoginActivity">
</activity>
</application>
</manifest>
If you look in your logcat it writes:
ComponentInfo{com.exmple.loop/com.example.loop.MainActivity}:
com.exmple.loop
I think it should be com.example.loop
Try remove this line and see if it works:
android:name="com.example.loop.LoopApplication"
Change your activity tag to this and it will run:
<activity
android:name="MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
There are many causes to this. I'll try to name as much as I can.
1.You tryed to add the library in your Java Build Path and not in the Android libraries.
rigt-click on your project> properties > Android. At the bottom there is a place for Android libraries.
2.Right-click your src folder>Build Path > Use as Source Folder
3.Right-click you src folder> Build Path> Configure output folder > set projects default output folder
4.Right-clikc project > Java Build Path > Order and Export > check Android Private Libraries
(You CAN'T have any library in Android Private Libraries and in the outside at the same time)
5.If you have set the project to use Maven and removed it after. Delete the bin folder and the pom.xml
6.Check if you R file is being generated. Delete it and see if it rebuild. If not look in your manifest or xml files for any error.
7.Check that Build Atomatically is checked.
Hope this help, I have had this that problem many times, and each time it was something else.
Good luck!
Edit: there is a 8 cause but this is not your case. Its if you forget to add the class to the manifest.
So after trying every bit of advice given to me I decided to create a new Android Project and copy all the files from the old project the appropriate folder in the new project. While this took a little bit of time that could have probably been shorter if I had messed with the original project some more, ultimately it did fix the error I was encountering and the project now runs.

Android SDK VS Facebook R class conflict?

Okay first of all what I am doing is trying to integrate my Android game which is fully functional and tested to be working code onto Facebook.
I have been following the Facebook tutorial on how to set it up for Facebook and have been using the Android SDK version of the support v4 file.
The problem I have been having seems to be a conflict between the two SDK's.
R cannot be resolved to a variable.
For example
MediaPlayer song = MediaPlayer.create(this.getContext(), R.raw.ironman);
R.raw.ironman is where the problem occurs, which is a reference to the raw folder in my resources directory, where the mp3 file ironman is found.
It uses the R class which is part of the Android SDK
I had my game setup this way and it works great until I try to add the features from the tutorial.
For example
if (user != null)
{
TextView welcome = (TextView) findViewById(R.id.welcome);
welcome.setText("Hello " + user.getName() + "!");
}
R.id.welcome
This uses the R class which is part of the Facebook SDK for accessing a control the way it looks.
Another thing I noticed was that it keeps deleting my Java files as well.
from what I have read on other posts on here this is due to problems with the XML file.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.SmashEm"
android:versionCode="2"
android:versionName="2.1" >
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="8" />
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="#drawable/thumb"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:configChanges="orientation|keyboardHidden"
android:name="com.example.SmashEm.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data android:value="#string/app_id" android:name=" com.facebook.sdk.ApplicationId"/>
<activity android:name="com.facebook.LoginActivity" android:label="#string/app_name"></activity>
</application>
</manifest>
Maybe I am going about this all wrong but I just thought I would give this a try.
Any help would be a appreciated and thanks.
Also I am pretty sure this is different then all the other threads I read so far but I could be wrong since I am not an expert in Java.

All referenced layouts and Buttons in ALL my java files all have warnings on them and I dont know how to fix it

All layouts and button references mentioned in my java files all have warnings on them. The warning is always, button or layout cannot be resolved to a variable. I asked other developers for help on this and I was asked to remove the import android.R;. I was told it's not needed.
I did this and now all the R'S throughout my project have that same warning, I seemed to have traded one problem for another.
is there a way I can manually change the lines in the R.java file in gen/ because all layouts are in place in the layout folders and all buttons in the xml files have android:id:#+id/ I don't know what I have to do for Java to read its references so I can get past this hump.
Manifest
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.CALL_PHONE"/>
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name=".ZohanActivity"
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=".MacAttack"
android:label="#string/app_name" >
</activity>
<activity
android:name=".ConsultationReq"
android:label="#string/app_name" >
</activity>
</application>
</manifest>
First of all are you sure it's a warning? or is it an error?
Secondly, never modify the R file, because it is generated automatically. So all your modifications will be lost.
I would have to guess it's an error and not a warning. Here is what I propose to you:
Clean your project and rebuild
right-click the error, click on quick fix and choose "import package_name.R"

Categories

Resources