Status Update
Comments
ji...@gmail.com <ji...@gmail.com> #2
As I understand it, we need to migrate namespace definitions both from AndroidManifest.xml
and from implicit definitions from applicationId
/ testApplicationId
? Is that right? So an 8.0 project would have a
namespace <n>
testNamespace <tn>
where <n> is taken from AndroidManifest.xml
package
definitions if present, and applicationId
if not, and <tn>
is testApplicationId
if present and <n>.test
if not?
mk...@google.com <mk...@google.com> #3
Sorry for the confusion. AGP would change how it computes the namespace for the androidTest variant. All the Upgrade assistant would need to do is update the source code for the import of the R
class.
ji...@gmail.com <ji...@gmail.com> #4
OK! And, I think, this should happen at the same time as the namespace
declaration is migrated from AndroidManifest.xml
?
ji...@gmail.com <ji...@gmail.com> #5 Restricted
ji...@gmail.com <ji...@gmail.com> #6
I would consider first adding the right new value to models (as a new property) and then, to avoid Studio interpreting manifests and build configurations, just update to whatever the synced value of this new property is.
mk...@google.com <mk...@google.com> #7
Updated version of this in #16 below
Currently, AUA removes the package
attribute from the main manifest and instead specifies that value via the namespace
DSL.
In addition to that, AUA should:
(1) Check for apackage
attribute in the (possibly non-existent) androidTestAndroidManifest.xml
. If there's a value there, it should be removed from that manifest, and if it's not equal tonamespace + ".test"
, it should be specified via thetestNamespace
DSL.Ifnamespace
==testNamespace
, this is problematic because the androidTest and regularR
classes will have the same namespace. Not sure what the best behavior is here? Maybe an error explaining that the user should first reset the androidTest AndroidManifest'spackage
attribute and change the androidTest source code package accordingly?
- (2)
Compare the newtestNamespace
with the oldAndroidProject.androidTestNamespace
from the model. If they are different, search the androidTest source code for references to anR
class namespaced withAndroidProejct.androidTestNamespace
, and change the namespace totestNamespace
.
ap...@google.com <ap...@google.com> #9
I have a draft implementation for the second part of (1) from namespace
and testNamespace
are equal. Is there any documentation we can point to explaining how the user should proceed? (My in-window space budget for explanatory text is pretty limited).
ap...@google.com <ap...@google.com> #10
+Amy
Amy, would it make sense to add documentation about setting the namespace for testing? Similar to what we have
It could mention the following:
- the default test namespace is
namespace
+".test"
- to customize the test namespace, use the
DSLtestNamespace - If setting a value for
testNamespace
, users should not set the same value asnamespace
, otherwise the test and testedR
andBuildConfig
classes will have the same namespace.
ap...@google.com <ap...@google.com> #11
Yeah definitely, I can draft it and send you a CL. Thanks! Looks like we might need to update this section too: package
attribute is only used to set the applicationId
when you first create your project, right (assuming people are setting the namespace using the DSL)?
Would it also be helpful to add a release note about this? I guess it's technically not new with Chipmunk, but looks like we didn't mention it in the last couple stable releases.
ap...@google.com <ap...@google.com> #12
Looks like we might need to update this section too:
https://developer.android.com/guide/topics/manifest/manifest-element#package
Yes, setting the package attribute in the manifest is deprecated, will cause build warnings in AGP 7.3.0, and will cause build errors in AGP 8.0.
Currently the package attribute is only used to set the applicationId when you first create your project, right (assuming people are setting the namespace using the DSL)?
The namespace
DSL will always trump the package
attribute, even when determining the applicationId
. E.g., if a dev sets package
to "com.example.package", namespace
to "com.example.namespace", and doesn't set the applicationId
explicitly in the DSL, the applicationId
will be "com.example.namespace".
Would it also be helpful to add a release note about this? I guess it's technically not new with Chipmunk, but looks like we didn't mention it in the last couple stable releases.
I think a 7.3 release note and an 8.0 release note since we're warning starting in 7.3 and will break the build in 8.0 when the manifest has a package attribute.
ap...@google.com <ap...@google.com> #13
Gotcha, thanks--sent you cl/449846661, to start. Is the warning/removal happening in certain Dolphin/EE preview releases, or not until the stable releases?
ap...@google.com <ap...@google.com> #14
Thanks!
Yes, the warning started in AGP 7.3.0-alpha04.
I expect we'll switch to an error in an early AGP 8.0 alpha.
ap...@google.com <ap...@google.com> #15
Okay sounds good, I added the Dolphin preview release note to cl/450515477 (messed up the previous CL) as well. Please let me know if you need help whenever the EE canary with the update is released!
ap...@google.com <ap...@google.com> #16
Updated version of #7:
Currently, AUA removes the package
attribute from the main manifest and instead specifies that value via the namespace
DSL.
In addition to that, AUA should:
- (1) Check for a
package
attribute in the (possibly non-existent) androidTestAndroidManifest.xml
. If there's a value there, it should be removed from that manifest, and if it's not equal to.namespace + ".test"
, it should be specified via thetestNamespace
DSL - (2) If
AndroidProject.androidTestNamespace != null
&&AndroidProject.androidTestNamespace != namespace
, set thetestNamespace
DSL withAndroidProject.androidTestNamespace
. - (3) If instead
AndroidProject.androidTestNamespace == namespace
, set thetestNamespace
DSL withAndroidProject.androidTestNamespace + ".test"
and warn the user that their androidTest code might no longer compile because the namespace of their androidTestR
class has changed fromAndroidProject.androidTestNamespace
toAndroidProject.androidTestNamespace + ".test"
, so they might need to modify their androidTest source code accordingly.
ji...@gmail.com <ji...@gmail.com> #17
LGTM. We should make sure to have a dac page ready (I guess for both the removal of the package
attribute, and the potential conflict between namespace
and testNamespace
and point the users to it whenever AUA does anything related to this change.
mk...@google.com <mk...@google.com> #18
I filed
ma...@gmail.com <ma...@gmail.com> #19
I've attached a project which demonstrates when a build will break in case (3) from #16.
In this project, the app gets its namespace ("com.example.namespace"
) from the package
attribute of the AndroidManifest.xml
.
The AndroidTest component gets its namespace from the testApplicationId
, and it's the same namespace as the app's.
The AndroidTest component calls com.example.namespace.R.string.app_android_test_string
in ExampleInstrumentedTest
, which compiles as-is (./gradlew :app:assembleAndroidTest
), but if we add namespace "com.example.namespace"
to the DSL, then it doesn't compile anymore because the AndroidTest component's namespace becomes "com.example.namespace.test".
Description
java.lang.ClassCastException: sg.bigo.live.ppi cannot be cast to sg.bigo.live.asd
at sg.bigo.live.c7q.get(Unknown Source:2)
at sg.bigo.live.xka.d(Unknown Source:11)
at sg.bigo.live.kka.u(Unknown Source:8)
at com.yy.iheima.startup.SplashAdvertView.onAttachedToWindow(SplashAdvertView.java:17)
at android.view.View.dispatchAttachedToWindow(View.java:20894)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3539)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3546)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3546)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3546)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3546)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3546)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3546)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3546)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2799)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2305)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:9133)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1232)
at android.view.Choreographer.doCallbacks(Choreographer.java:1029)
at android.view.Choreographer.doFrame(Choreographer.java:934)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1217)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:233)
at android.os.Looper.loop(Looper.java:344)
at android.app.ActivityThread.main(ActivityThread.java:8212)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:584)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1034)
jadx disassemble result:
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import android.util.Base64;
import com.google.android.gms.internal.p001firebaseauthapi.zzwe;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.List;
import sg.bigo.live.t8l;
/* loaded from: classes.dex */
public class c7q implements asd, etr {
public static volatile c7q y;
public Object z;
public /* synthetic */ c7q(Context context) {
this.z = new HashMap();
this.z = context;
}
public /* synthetic */ c7q(Object obj, Object obj2) {
this.z = obj;
this.z = obj2;
}
public /* synthetic */ c7q(String str) {
this.z = new Intent();
this.z = str;
}
public /* synthetic */ c7q(asd asdVar, esd esdVar) {
this.z = asdVar;
this.z = esdVar;
}
public static c7q z(Context context) {
if (context == null) {
nwp.e("[TinyDataManager]:mContext is null, TinyDataManager.getInstance(Context) failed.");
return null;
}
if (y == null) {
synchronized (c7q.class) {
if (y == null) {
y = new c7q(context);
}
}
}
return y;
}
public void a(Context context) {
Class<?> x = t8l.y.z.x((String) this.z);
if (x != null) {
((Intent) this.z).setClass(context, x);
Intent intent = (Intent) this.z;
if (intent == null || intent.getComponent() == null) {
return;
}
Class[] l0 = qc.l0(x);
if (l0 != null && l0.length != 0) {
qc.I(intent);
if (context instanceof p17) {
new sg.bigo.mobile.android.srouter.api.interceptor.y(context, x, intent, -1).z();
return;
}
qc.g1(intent);
}
qc.v1(context, intent, -1, x);
}
}
public void b(Activity activity, int i) {
Class<?> x = t8l.y.z.x((String) this.z);
if (x != null) {
((Intent) this.z).setClass(activity, x);
Intent intent = (Intent) this.z;
if (intent == null || intent.getComponent() == null) {
return;
}
Class[] l0 = qc.l0(x);
if (l0 != null && l0.length != 0) {
qc.I(intent);
if (activity instanceof p17) {
new sg.bigo.mobile.android.srouter.api.interceptor.y(activity, x, intent, i).z();
return;
}
qc.g1(intent);
}
qc.v1(activity, intent, i, x);
}
}
@Override // sg.bigo.live.asd
public ft2 get(Object obj) {
ft2 ft2Var = ((asd) this.z).get(obj);
if (ft2Var == null) {
((esd) this.z).p();
} else {
((esd) this.z).c(obj);
}
return ft2Var;
}
public boolean u(
if (TextUtils.isEmpty(str)) {
nwp.w("pkgName is null or empty, upload ClientUploadDataItem failed.");
return false;
} else if (yyp.v(hnVar, false)) {
return false;
} else {
if (TextUtils.isEmpty(hnVar.d())) {
hnVar.f(yyp.y());
}
hnVar.g(str);
ozp.z((Context) this.z, hnVar);
return true;
}
}
@Override // sg.bigo.live.asd
public boolean v(rsh rshVar) {
return ((asd) this.z).v(rshVar);
}
@Override // sg.bigo.live.asd
public ft2 w(Object obj, ft2 ft2Var) {
((esd) this.z).k();
return ((asd) this.z).w(obj, ft2Var);
}
@Override // sg.bigo.live.etr
public void x(Object obj) {
bur burVar = (bur) obj;
String str = burVar.z;
msh.u(str);
List i = new com.google.android.gms.internal.p001firebaseauthapi.y(new du1(new kbr())).i(str);
if (i.size() < 2) {
throw new RuntimeException("Invalid idToken ".concat(str));
}
String str2 = (String) i.get(1);
try {
uur z = uur.z(new String(str2 == null ? null : Base64.decode(str2, 11), "UTF-8"));
zzwe zzweVar = new zzwe(burVar.y, burVar.z, Long.valueOf(z.y.longValue() - z.z.longValue()), "Bearer");
Object obj2 = this.z;
jqr.a((jqr) obj2, zzweVar, null, Boolean.FALSE, (b3r) obj2, this);
} catch (UnsupportedEncodingException e) {
throw new RuntimeException("Unable to decode token", e);
}
}
@Override // sg.bigo.live.asd
public int y(rsh rshVar) {
return ((asd) this.z).y(rshVar);
}
@Override // sg.bigo.live.etr
public void zza(String str) {
((b3r) this.z).y(xoq.z(str));
}
}