Skip to content
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

Uglify option prevents the generation of java class #1039

Closed
fpaaske opened this issue Sep 6, 2019 · 3 comments
Closed

Uglify option prevents the generation of java class #1039

fpaaske opened this issue Sep 6, 2019 · 3 comments

Comments

@fpaaske
Copy link

fpaaske commented Sep 6, 2019

Environment
tns info

✔ Component nativescript has 6.1.0 version and is up to date.
✔ Component tns-core-modules has 6.1.0 version and is up to date.
✔ Component tns-android has 6.1.0 version and is up to date.
✔ Component tns-ios has 6.1.0 version and is up to date.

node -v
v12.8.0

Relvant section of webpack.config.js

    // Add your custom Activities, Services and other Android app components here.
    const appComponents = [
        "tns-core-modules/ui/frame",
        "tns-core-modules/ui/frame/activity",
        resolve(__dirname, "src/app/call-state-listener.ts"),
    ];

call-state-listener.ts:

@JavaProxy('com.company.BroadcastReceiver.CallStateListener')
export class CallStateListener extends android.content.BroadcastReceiver {

  constructor() {
    super();
    global.__native(this); // necessary in TS constructors if extending native class
  }

  public onReceive(context: android.content.Context, intent: android.content.Intent) {
  }
}

AndroidManifest.xml

		<receiver android:name="com.company.BroadcastReceiver.CallStateListener">
			<intent-filter>
				<action android:name="android.intent.action.PHONE_STATE" />
				<action android:name="android.intent.action.PHONE_STATE_CHANGED" />
				<action android:name="android.intent.action.NEW_OUTGOING_CALL" />
			</intent-filter>
		</receiver>
	</application>
</manifest>

Describe the bug

When using the --env.uglify flag, the generated .class-file is missing from the apk-file.
Without the flag, it works fine.

Might be related to #564

@RadouaneRoufid
Copy link

Any news on this ?
I had opened #564 and still having the problem in tns 6.1.2

@RadouaneRoufid
Copy link

I found the solution. "noEmitHelpers": true, must be present in compilerOptions in tsconfig.json while build with env.uglify with custom activity.

@Fatme
Copy link
Contributor

Fatme commented Sep 23, 2019

@RadouaneRoufid,

It is recommend to set noEmitHelpers: true regardless if you building with env.uglify or extending platform native classes. More info can be found here.

However, I'm glad to hear you resolved your issue so I'm closing this thread.

@Fatme Fatme closed this as completed Sep 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants