manifest


Android get GSF ID (Google Services Framework Identifier)

The Google Services Framework Identifier (GSF ID) is a unique 16 character hexadecimal number that your device automatically requests from Google as soon as you log to your Google Account for the first time. For a specific device, the GSF ID will change only after a factory reset. To get this information programmatically, you need to do two steps.

A) Add the following to your manifest


<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />

B) Execute the following code


private static final Uri sUri = Uri.parse("content://com.google.android.gsf.gservices");
public static String getGSFID(Context context) {
 try {
  Cursor query = context.getContentResolver().query(sUri, null, null, new String[] { "android_id" }, null);
  if (query == null) {
   return "Not found";
  }
  if (!query.moveToFirst() || query.getColumnCount() < 2) {
   query.close();
   return "Not found";
  }
  final String toHexString = Long.toHexString(Long.parseLong(query.getString(1)));
  query.close();
  return toHexString.toUpperCase().trim();
 } catch (SecurityException e) {
  e.printStackTrace();
  return null;
 } catch (Exception e2) {
  e2.printStackTrace();
  return null;
 }
}


Creating Jar with Intellij IDEA 2017.3 – no main manifest attribute, in .jar 1

Recently we tried to create a Jar file from IntelliJ IDEA 2017.3 using Maven.

After building the artifact, we got the error no main manifest attribute, in $FILE.jar while executing the jar file created by IntelliJ.
After extracting the jar we observed that there was a manifest file but not the one that was specified while creating the artifact.

After some serious google-fu, we got to the following bug ticket.
Apparently, IntelliJ does not read the manifest file that is located in the src/main/java folder!
Working Solution: As suggested in the ticket, we moved the META-INF folder to src/main/resources and rebuild the artifact.