ProGuard issues with Android Archieve(.aar) library - android-studio

I've a library project which I want to distribute, in AAR format. I've applied ProGuard on it.
ProGuard settings works well if I use this lib as a module, but not when I use resulting AAR. Basically it fails with exception "java.lang.IllegalArgumentException: already added Lmy/lib/package/name/R;" in Application project.
ProGuard is renaming one of my lib class to R, and I feel which is causing problem in Application project as R is used for Resources.
How do I specify proguard mapping in Studio to tell it not to rename to R.
Update:
after adding AAR file as a new module, am getting this error:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lmy/lib/package/name/R;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)
at com.android.dx.command.dexer.Main.run(Main.java:246)
at com.android.dx.command.dexer.Main.main(Main.java:215)
at com.android.dx.command.Main.main(Main.java:106)

Okay then, answering myself.
Tried running ProGuard manually on .aar, worked with latest version v5.2.1. Didn't work with default version v4.7 which came with Studio v1.2.2. Hope this helps.

Related

Debug target is an old version of NUnit that isn't present on computer

When trying to debug a project which I have successfully debugged many times before and which compiles without incident, I'm now getting this error:
Visual Studio cannot start debugging because the debug target 'C:\Program Files (x86)\NUnit 2.6.2\bin\nunit.exe' is missing. Please build the project and retry, or set the OutputPath and AssemblyName properties appropriately to point at the correct location for the target assembly.
Looking at Program Files (x86), I can see that the reason VS can't find the file is that it doesn't exist. The version of NUnit it should be looking for is 2.6.4, not 2.6.2.
What I can't find, however, is any way to tell VS where to look. The OutputPath and AssemblyName properties referenced in the error message both seem unrelated to the issue, and there isn't any setting I can find that references NUnit at all, much less a particular version of it.
In following advice from some of the many other questions about this error, I have tried the following without success:
Cleaning and rebuilding the solution
Cleaning and rebuilding the individual projects within the solution
Looking at the project and solution files in a text editor (They all show NUnit 2.6.4)
Making sure the projects are all checked in the Configuration Manager
Checking the projects' debug properties
As stated above, neither the .sln files nor any of the .csproj files contained any reference to NUnit 2.6.2, but I finally found a reference to it in a .csproj.user file for one of the projects:
<StartProgram>C:\Program Files %28x86%29\NUnit 2.6.2\bin\nunit.exe</StartProgram>
Changing the version number there fixed the issue.

Warning LNK4075 when a C++/CLI project references a static lib project with /ZI (Edit And Continue)

I have the following projects in a Visual Studio 2012 solution:
Native (no /clr) static lib project, compiled with /ZI for Edit And Continue.
C++/CLI DLL project, which references the above static lib.
The C++/CLI project builds with the following warning:
warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/OPT:LBR' specification
If /OPT:NOLBR is added to the linker options of the C++/CLI project, the warning becomes:
warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/INCREMENTAL:NO' specification
Any attempt to change the incremental linkage setting of the C++/CLI project doesn't change the warning (C++/CLI projects never link incrementally anyway).
I understand that I won't be able to use Edit And Continue in the C++/CLI project, because this is not supported. Indeed, changing /ZI to /Zi (disabling Edit And Continue) in the static lib project eliminates the warning, but I can't do that - other non-CLR consumers of that lib need to use Edit And Continue.
How can I get rid of this warning without disabling Edit And Continue in the static lib (and hopefully without maintaining separate build configuration for native and CLR users of the static lib)? I mean, is there any way to ask the linker to ignore the /EDITANDCONTINUE directive that is embedded in the referenced static lib (much in the same way that /NODEFAULTLIB can ignore /DEFAULTLIB directives)?
I have created a minimal VS solution that reproduces the described issue.
due to '/OPT:LBR' specification
This is a nonsense error message, that linker option is only effective for ARM binaries. This is simply a bug, using /OPT:NOLBR takes the sting out of it and you get the real warning.
Which is accurate enough, although it doesn't win any prizes either, you asked for Edit+Continue support in your static lib project but that is not available for a mixed-mode .NET assembly. The undocumented /IGNORE linker option is available to suppress warning messages but this one is ranked as an "unignorable warning" by Chapell.
You'll have to live with this warning as long as you don't want to change your static lib project. It is completely benign. You won't get it when you recompile it with /Zi.
There is no other way than to
disable "Edit And Continue" in the library
create a separate build configuration for "Edit And Continue (/ZI)" and "Program Database (/Zi)"
Of course: I am not aware that there is a predefined macro to determine between /ZI and /Zi... so you need to define your own preprocessor directive to distinguish between these configurations...
I had the same problem and found the only solution is to delete the .vcxproj and .sln files of the project and create the project again.
But then in an old copy of the same project I found a better solution: I changed in the projectname.vcxproj file the line
Profile true
to
Profile false
and LNK4075 warnings disappeared.
It had been the Visual Studio Profiler who had caused the troubles.

Typescript giving "Output Generation Failed" in Visual Studio 2012 with 0.9.5

I've been using Typescript 0.9.5 for the last few days, and then suddenly today the JavaScript files just stopped being generated. I see an error "Output generation failed" in the Visual Studio status bar, but nothing in any of the output windows.
I've rebooted, and restarted Visual Studio, disabled Web Essentials, tried all the usual things.
The files are set as TypescriptCompile in the properties. I've tried adding new files, or editing old ones with no effect. The Project file hasn't been changed as far as I can tell (its in TFS and none of the TypeScript sections have been altered).
I've made sure both files are checked out, still nothing.
Update: I've managed to compile manually using tsc.exe from the command line, so it must be something in Visual Studio.
OK, so I solved the problem.
One of my files contained invalid typescript, specifically trying to export a class when not inside a module. This caused all typescript files to fail to generate, but with no useful error message.
The following file would cause the problem:
export class Test {
public DoSomething() {
}
}
Either removing the export keyword, or adding a wrapping module solved the problem.
I've raised it as an issue here: https://typescript.codeplex.com/workitem/2109
Update: More details.
The above syntax is valid if you are using the CommonJS or AMD module patterns.
To enable this in visual studio you need to edit the .csproj file and insert a new PropertyGroup:
<TypeScriptModuleKind>AMD</TypeScriptModuleKind>
If you have an export outside of an internal module Typescript tries to compile it as either commonjs or amd module format. The compilation will fail if the a --module flag is not present on the command line. Use your project properties to set it to the desired value (probably amd in your case).
More info on TypeScript modules : http://www.youtube.com/watch?v=KDrWLMUY0R0&hd=1

Fail to load manifest error

What does this message means? How to solve this error?
Error 1 general error c1010070: Failed to load and parse the manifest. The system cannot find the file specified. ..\DebugObj\Example1\Example1.exe.intermediate.manifest Example1
I had the same problem on a project I inherited from a pre-2008 Visual studio.
It was not practical for me to add a Main function as sugested by the previous answer. I googled for a while but could not find the root of the problem.
A friend of mine gave me the following solution.
It turns out that the old project included a "example.manifest" file entry in the Resource File Folder in Visual Studio's Solution Explorer for the project. When trying to build the project, VS 2008 was trying to load "example.manifest", which did not exist on the new 2008 folder structor (it was not needed).
So the solution was as simple as removing the entry "example.manifest" from the Resouce Files folder. Rebuilt, and no more errors!. Hope that helps
to fix that error you need to have an entry point in your solution.
just create a main.cpp with a main method... just like this.
in "main.cpp"
void main(){}
then compile and it will get rid of the error.
Had similar issue myself. Converted a VS2005 project to VS2010.
I was using the option, Linker -> Manifest File -> Additional Manifest Dependencies: type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='' publicKeyToken='6595b64144ccf1df' language=''
The conversion garbled it into type=%27win32%27...etc
Fixing this option to the correct format, type='win32'..etc resolved the issue. But not before I accidentally used the format, type=win32...etc and received the same error.

How do I eliminate error C2859 when trying to use a precompiled header with VS2010 (VC100) in debug mode?

I am trying to upgrade an old solution to use VS2010 (VC100).
I have it setup so that stdafx.cpp will create a precompiled header stdafx.pch from stdafx.h. Then all the other .cpp files that include stdafx.h are instructed to use the precompiled header.
These posts helped me get this far:
Visual C++ Precompiled Headers errors
Precompiled Headers
Now all is fine when I build in release mode. However when I try and build in debug mode I get a whole heap of errors saying:
Error 1 error C2859: [removed]\debug\vc100.idb is not the idb file that was used when this precompiled header was created, recreate the precompiled header.
I believe that this .idb file is an intermediate debug file created by Visual Studio.
Why am I getting this error? In other words why did it not use this .idb file when it created the precompiled header?
I'm not sure what further information you need to be able to give me answer so just ask if there is more information that I need to provide.
Thanks to a colleague I got the answer.
The problem was that stdafx.cpp had Debug Information Format set to Program Database (/Zi) where as all the other files had it set to Program Database for Edit and Continue (/ZI).
Changing them all to Program Database for Edit and Continue (/ZI) and doing a full rebuild solved the problem.
I guess the upgrade screwed it up somehow.
I've hit this error with VS2005 when compiling a project where the $(ProjectName) is different from the actual output file of the project (i.e. Linker > Output File isn't set to the default of $(OutDir)\$(ProjectName).exe but to something else, e.g. $(OutDir)\$(ProjectName)-custom_postfix.exe)
In this case, and apparently only when doing a Rebuild-Project-Only, the vc80.pdb seems to be looked up wrongly.
What helped me was to additionally set C/C++ > Output Files > Progam Database File Name to $(IntDir)\$(TargetName).pdb. (Instead of the default vc80.pdb)
select Disable for the Debug Information Format in the Properties page for stdafx.cpp, then go back and select Inherit from parent worked for me.
Maybe your release build is configured to write file [removed]\debug\vc100.idb instead of [removed]\release\vc100.idb? Check the project settings for your release build and make sure there are no hardcoded path components like that.
Here's how I just fixed this error on Visual Studio 2008:
Background:
I have a solution that contains two sub-projects.
One project compiles the .dll;
One project compiles the .exe that used this .dll;
The .exe project is dependent on the .dll project;
Problem: I had both of the projects dumping their output into the same directory, i.e. both "OutPutDirectory" and "IntermediateDirectory" set to write to a common directory in the root, "../$(ConfigurationName)".
Cause of error:
The cause of this error was that when the .dll project was compiled, it created the precompiled header (*.pch) in the same directory as the .exe directory, and when the .exe project was compiled, it promptly overwrote the precompiled header (*.pch) from the .dll project.
The fix:
To fix this, I changed the "IntermediateDirectory" for both sub-projects to "temp", so that the temporary files (including the precompiled header files) were written to different directories.

Resources