Extension Template Repository

Sorry, it is my mistake.
A well known copy-paste issue.

1 Like

I just clone new template and trying to cmd proguard but getting same error
Extension build successfully but not working on proguard cmd

[proguard] carry the GNU General Public License as well. Alternatively, you can
[proguard] apply for an exception with the author of ProGuard.
[proguard] Reading input...
[proguard] Reading program jar [C:\extension-template\build\externalComponents-classes\com.varsha.revealeffect.jar] (filtered)
[proguard] Reading library jar [C:\extension-template\lib\ant-contrib\ant-contrib-1.0b3.jar] (filtered)
[proguard] Reading library jar [C:\extension-template\lib\appinventor\AndroidRuntime.jar] (filtered)
[proguard] Reading library jar [C:\extension-template\lib\appinventor\AnnotationProcessors.jar] (filtered)
[proguard] Reading library jar [C:\extension-template\lib\appinventor\Barcode.jar] (filtered)
[proguard] Reading library jar [C:\extension-template\lib\appinventor\CommonVersion.jar] (filtered)
[proguard] Reading library jar [C:\extension-template\lib\appinventor\QRGenerator.jar] (filtered)
[proguard] Reading library jar [C:\extension-template\lib\appinventor\acra-4.4.0.jar] (filtered)
[proguard] Reading library jar [C:\extension-template\lib\appinventor\android.jar] (filtered)
[proguard] Reading library jar [C:\extension-template\lib\appinventor\androidsvg.jar] (filtered)
[proguard] Reading library jar [C:\extension-template\lib\appinventor\annotation.jar] (filtered)
[proguard] Reading library jar [C:\extension-template\lib\appinventor\apksigner.jar] (filtered)

BUILD FAILED
C:\extension-template\build.xml:86: The following error occurred while executing this line:
C:\extension-template\build.xml:101: The following error occurred while executing this line:
C:\extension-template\build.xml:178: Can't read [C:\extension-template\lib\appinventor\apksigner.jar] (only DEFLATED entries can have EXT descriptor)

Total time: 4 seconds
Picked up _JAVA_OPTIONS: -Xmx1024M

varsha@varsha-PC MINGW64 /c/extension-template (master)

I have built an extension and tried to download a file to the ASD (app-specific dir). This works fine on devices with API < 29.
But on devices with API > 28 I get this error:

grafik
I get the same error with the full path.

Here is my code:

Java

@SimpleFunction(description = "Downloads APK to AppSpecificDir (ASD): /storage/emulated/0/Android/data//files/. Note: No WRITE permission required.")
public void DownloadApkToASD(String url,String fileName){

	String name = fileName;
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
request.setMimeType(URLConnection.getFileNameMap().getContentTypeFor(url));
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
	
	int version_api = Build.VERSION.SDK_INT;
	if (version_api > 28){
	request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS,name); //downloads to /storage/emulated/0/Download, not to the ASD (as it should)
	}
	else {
	request.setDestinationInExternalPublicDir(context.getExternalFilesDir(null).toString().replace("/storage/emulated/0",""), name);  // doesn't work for API > 28	
	}

DownloadManager dm = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
dm.enqueue(request);

}

Does anyone have any idea how to solve this?
I compiled it with the old Extension Template (without AndroidX):
import android.support.v4.content.FileProvider;

Can you please verify that API levels you have mentioned are correct? Because I am confused.

Sorry, but I don't understand.
I only used this in my code:

if (version_api > 28) {
...

Is something wrong with it?

request.setDestinationInExternalPublicDir(context.getExternalFilesDir(null).toString().replace("/storage/emulated/0",""), name);

works fine for devices with Android 9 and below (API < 29), but NOT on Android 10 and above (API > 28).

6 posts were split to a new topic: Problems building extension from appinventor-sources

today i tried to build aix with extension-template and
when i run ant extensions the result is BUILD SUCCESSFUL but when i try to run
ant extensions -Dproguard=1 it show me the BUILD FAILED result.

how do i solve this problem?

I'm going to need more information about how it failed. Do you have a stack trace or other error message?

No, or maybe i dont understand :confused:

Probably it needs some changes:

1 Like

@vknow360, @ewpatton

And i want to ask i am using git, and when i want to build aix in extension-template i left click in extension-template folder and build using gitbash (I build my aix outside the src folder).

Salman@DESKTOP-BK3S90V MINGW64 ~/extension-template (master)

is what i did right?

And if I want to upgrade my extension-template with the latest one
do I just need to run upgrade-appinventor.sh?

@ewpatton I see there seems to be a problem in the extension template because I have tried to build my aix many times with the command ant extensions -Dproguard=1 but the result is still BUILD FAILED

This is the source code I'm trying to build :
SalmanTest.txt (1.7 KB)

And this is the build log result :

$ ant extensions -Dproguard=1
Buildfile: C:\Users\Salman\extension-template\build.xml

javac:
    [javac] Compiling 1 source file to C:\Users\Salman\extension-template\build\classes
    [javac] warning: [options] bootstrap class path not set in conjunction with -source 1.7
    [javac] warning: In component SalmanTest, method ReturnText is missing a description.
    [javac] Note: Wrote file file:/C:/Users/Salman/extension-template/build/classes/simple_components.json
    [javac] warning: In component SalmanTest, method ReturnText is missing a description.
    [javac] Note: Wrote file file:/C:/Users/Salman/extension-template/build/classes/simple_components.txt
    [javac] Note: Wrote file file:/C:/Users/Salman/extension-template/build/classes/simple_components_build_info.json
    [javac] warning: In component SalmanTest, method ReturnText is missing a description.
    [javac] Note: Wrote file file:/C:/Users/Salman/extension-template/build/classes/AutogeneratedOdeMessages.java
    [javac] Note: Wrote file file:/C:/Users/Salman/extension-template/build/classes/ComponentsTranslation.java
    [javac] warning: In component SalmanTest, method ReturnText is missing a description.
    [javac] 4 warnings

process:
     [java]
     [java] Extensions : Generating extensions
     [java]
     [java] Extensions : Generating files [com.SalmanDev.Test]
     [java] Extensions : Copying file com\SalmanDev\Test\SalmanTest.class
     [java] Extensions : Successfully created com.SalmanDev.Test build info file
     [java] Extensions : Successfully created com.SalmanDev.Test extension properties file

unjarAllExtensionLibraries:

unjarExtensionLibraries:

unjarExtensionLibraries:

jarAllExtensions:

jarExtension:
      [jar] Building jar: C:\Users\Salman\extension-template\build\externalComponents-classes\com.SalmanDev.Test.jar

ProGuard:
 [proguard] ProGuard, version 6.2.2
 [proguard] ProGuard is released under the GNU General Public License. You therefore
 [proguard] must ensure that programs that link to it (net.sf.antcontrib.logic, ...)
 [proguard] carry the GNU General Public License as well. Alternatively, you can
 [proguard] apply for an exception with the author of ProGuard.
 [proguard] Reading input...
 [proguard] Reading program jar [C:\Users\Salman\extension-template\build\externalComponents-classes\com.SalmanDev.Test.jar] (filtered)
 [proguard] Reading library jar [C:\Users\Salman\extension-template\lib\ant-contrib\ant-contrib-1.0b3.jar] (filtered)
 [proguard] Reading library jar [C:\Users\Salman\extension-template\lib\appinventor\AndroidRuntime.jar] (filtered)
 [proguard] Reading library jar [C:\Users\Salman\extension-template\lib\appinventor\AnnotationProcessors.jar] (filtered)
 [proguard] Reading library jar [C:\Users\Salman\extension-template\lib\appinventor\Barcode.jar] (filtered)
 [proguard] Reading library jar [C:\Users\Salman\extension-template\lib\appinventor\CommonVersion.jar] (filtered)
 [proguard] Reading library jar [C:\Users\Salman\extension-template\lib\appinventor\QRGenerator.jar] (filtered)
 [proguard] Reading library jar [C:\Users\Salman\extension-template\lib\appinventor\acra-4.4.0.jar] (filtered)
 [proguard] Reading library jar [C:\Users\Salman\extension-template\lib\appinventor\android.jar] (filtered)
 [proguard] Reading library jar [C:\Users\Salman\extension-template\lib\appinventor\androidsvg.jar] (filtered)
 [proguard] Reading library jar [C:\Users\Salman\extension-template\lib\appinventor\annotation.jar] (filtered)
 [proguard] Reading library jar [C:\Users\Salman\extension-template\lib\appinventor\apksigner.jar] (filtered)

BUILD FAILED
C:\Users\Salman\extension-template\build.xml:86: The following error occurred while executing this line:
C:\Users\Salman\extension-template\build.xml:101: The following error occurred while executing this line:
C:\Users\Salman\extension-template\build.xml:178: Can't read [C:\Users\Salman\extension-template\lib\appinventor\apksigner.jar] (only DEFLATED entries can have EXT descriptor)

Total time: 4 seconds

Try cherry-picking this commit onto your repo:

1 Like

@ewpatton proguard worked after I added this line :
<exclude name="*/apksigner.jar"/>

below this line :
<exclude name="*/dx.jar"/>

Looks like you have to update your extension-template with that line :star_struck:


btw, why after I build aix with command ant ant extensions -Dproguard=1 it gives me 2 file,
and after i delete those two files and try to build with command ant extensions it gives me 1 aix.
and you see there is a file with the extension .map
is that not a problem?

The .map file is the mapping that proguard produces to map the obfuscated names back to their original names. If you don't include the -Dproguard=1, proguard won't be invoked so no mapping file will be produced. Both builds will yield the .aix file.

1 Like

so is tht normal?

Yes, that's expected. You mainly need the .map file for interpreting stack traces from the app since otherwise they're unintelligible. For the most part you can probably ignore the map file. If you plan to release the extension to others, you may want to keep each one around (you'll have to save each .map file per build) so that you can respond to issues that come up in the obfuscated code.

1 Like