[Android] JavierAlonso:
There is already a label with that name.

Hi! :cowboy: I'm here again to go to the next level about smali and rejects. :highfive:

Today I'm not going to explain you a reject at all; I'm going to explain how to fix a very common issue when making fullota.

In Terminal, you'll get something like this:

out/framework2/smali/com/android/internal/app/IAppOpsService$Stub.smali[695,4] There is already a label with that name.
Exception in thread "main" brut.androlib.AndrolibException: Could not smali file: com/android/internal/app/IAppOpsService$Stub.smali
at brut.androlib.src.SmaliBuilder.buildFile(SmaliBuilder.java:71)
at brut.androlib.src.SmaliBuilder.build(SmaliBuilder.java:55)
at brut.androlib.src.SmaliBuilder.build(SmaliBuilder.java:41)
at brut.androlib.Androlib.buildSourcesSmali(Androlib.java:354)
at brut.androlib.Androlib.buildSources(Androlib.java:294)
at brut.androlib.Androlib.build(Androlib.java:280)
at brut.androlib.Androlib.build(Androlib.java:255)
at brut.apktool.Main.cmdBuild(Main.java:225)
at brut.apktool.Main.main(Main.java:84)

Why we're getting this error? Very simple: sometimes MiPatcher (or just you when patching manually) gets confused due to it found the same line twice in a smali, so it applies a duplicate diff, or something like that, so it results in "There is already a label with that name."

And the question is...How can we fix it? Quite simple too. Firstly, locate which file is corrupted. In my case is:

out/framework2/smali/com/android/internal/app/IAppOpsService$Stub.smali[695,4] There is already a label with that name.

So I'll open "IAppOpsService$Stub.smali", which should be located at:

patchrom/device/framework2/smali/com/android/internal/app/

. After that, it's time to find out the line that's wrong.

Terminal output tells it. In my case:

IAppOpsService$Stub.smali[695,4]

I'll have to go to line 695 (use Ctrl+I). When I'm looking at there, I found this:

:sswitch_d
const-string v7, "com.android.internal.app.IAppOpsService"

invoke-virtual {p2, v7}, Landroid/os/Parcel;->enforceInterface(Ljava/lang/String;)V

invoke-virtual {p2}, Landroid/os/Parcel;->readStrongBinder()Landroid/os/IBinder;

move-result-object v7

invoke-static {v7}, Lcom/android/internal/app/IOpsCallback$Stub;->asInterface(Landroid/os/IBinder;)Lcom/android/internal/app/IOpsCallback;

Now you've to be focused in which label could be repeated. Applying logic, the line that's causing the issue is:

:sswitch_d

Why? Coz the other lines uses values that are used all over the file. To check that ":sswitch_d" is the label which is repeated, just look for the same code in that file (use Ctrl+f).

I found this code some lines up:

[B][COLOR="Blue"]:sswitch_d[/COLOR][/B]
const-string v6, "com.android.internal.app.IAppOpsService"

invoke-virtual {p2, v6}, Landroid/os/Parcel;->enforceInterface(Ljava/lang/String;)V

.line 197
invoke-virtual {p0}, Lcom/android/internal/app/IAppOpsService$Stub;->resetCounters()V

.line 198
invoke-virtual {p3}, Landroid/os/Parcel;->writeNoException()V

goto/16 :goto_0

Realise that both codes are too similar. That's why I think that MiPatcher fails. So what to do?

To fix this issue, you have to mix both codes. Look for what lines coincide, and then mix the ones that doesn't match.

Be careful, a different value (v7, p2) doesn't mean that the line doesn't coincide.

In my case, I deleted the first code (that was around line 695, which was failing) and I mixed it content into the second code. After editing, it looked in this way:

:sswitch_d
const-string v6, "com.android.internal.app.IAppOpsService"

invoke-virtual {p2, v6}, Landroid/os/Parcel;->enforceInterface(Ljava/lang/String;)V

invoke-virtual {p2}, Landroid/os/Parcel;->readStrongBinder()Landroid/os/IBinder;

move-result-object v7

invoke-static {v7}, Lcom/android/internal/app/IOpsCallback$Stub;->asInterface(Landroid/os/IBinder;)Lcom/android/internal/app/IOpsCallback;

.line 197
invoke-virtual {p0}, Lcom/android/internal/app/IAppOpsService$Stub;->resetCounters()V

.line 198
invoke-virtual {p3}, Landroid/os/Parcel;->writeNoException()V

goto/16 :goto_0

Finally, save your changes and try to make fullota again. I'll work :laugh: