I'm going to use Sentry for My Android app. My company is using a self-hosted Sentry, version 9.0.0. I get the below answer when I run sentry-cli info command using sentry-cli:
Sentry Server: https://log.mydomain.com
Default Organization: -
Default Project: -
It didn't recognize Default Organization and Default Project. How can I set these data?
Did you define the Sentry Project and Organization somewhere?
Some commands require your Sentry Organization and/or Projects slugs.
There are multiple ways to provide these values:
Command line argument, like; --org
Environment variables, like; SENTRY_ORG
Adding to a configuration file
As per the docs:
You can add to the configuration file (~/.sentryclirc) the keys:
defaults.project
defaults.org
Or use the environment variables: SENTRY_PROJECT and SENTRY_ORG
Related
I have some code that is written in Java and Kotlin for Android; the Java part can be translated into Kotlin using the Android Studio. Most of this code is business; that means, independent on any hardware or platform specifics; some Android specific classes (like "Bitmap") can be replaced by abstract or general self-defined classes.
As already known, Kotlin business code can be used in multiplatform applications for Android and iOS. Description here : https://kotlinlang.org/docs/multiplatform-mobile-integrate-in-existing-app.html .
Xamarin is used for multiplatform apps, too.
On the other hand, there is a way to include Kotlin code in Xamarin projects. For this purpose, the Xamarin.Kotlin.StdLib is used : https://libraries.io/nuget/Xamarin.Kotlin.StdLib .
My question: Is it possible to develop a Xamarin project (maybe with Xamarin Forms) that includes the Kotlin business code and will work in both Android and iOS environments?
Here are some instructions.
ANDROID STUDIO
Create a new Project: "File -> New -> New Module -> Kotlin
Multiplatform Shared Module".
Follow these instructions:
https://kotlinlang.org/docs/multiplatform-mobile-integrate-in-existing-app.html
until "Run your cross-platform application on Android".
For Android we're finished. Following steps are only for iOS.
We now assume that there is a module with the name "shared". If this module has another name, please replace it in the following instructions.
XCODE:
The following instructions are similar to that in https://kotlinlang.org/docs/multiplatform-mobile-integrate-in-existing-app.html#make-your-cross-platform-application-work-on-ios . The difference is that we don't want to build the app now, but a framework.
File New - Project.
Select the template for "Framework" and click "Next".
Choose a product name (for example, "KmmExample"). Language:
Objective C
Build Phases - New Run Script Phase:
cd "$SRCROOT/.."
chmod +x gradlew
./gradlew :shared:embedAndSignAppleFrameworkForXcode
Move the Run Script phase up so that it is located after the
"Dependencies" item.
On the Build Settings tab, switch to "All" build settings.
In the Search Paths paragraph, specify the Framework Search Path for both Debug and Release:
$(SRCROOT)/../shared/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)
In the Linking paragraph:
Specify the "Mach-O Type" as "Static Library".
Specify the Other Linker Flags as
$(inherited) -framework shared
In the Architectures paragraph, "Architectures" may be unchanged or changed to "$(ARCHS_STANDARD_INCLUDING_64_BIT)".
Build the project.
If successful, there will be a folder structure inside "shared/build". There will be a subfolder "xcode-frameworks". In the "Debug" resp. "Release" directory, there will be subfolder(s) with the name(s) of the iOS device(s) or simulator(s). For example, "iphonesimulator15.5". It contains another subfolder: "shared.framework". In the "Headers" you find a "shared.h", and there is the library itself: "shared". (In the "shared/build" folder there will be also a "bin" directory with device and simulator names containing "debugFramework" and similar structures inside.)
OBJECTIVE SHARPIE
Download the "Objective Sharpie" tool
(https://learn.microsoft.com/en-us/xamarin/cross-platform/macios/binding/objective-sharpie/)
In order to create "ApiDefinitions.cs" from shared.h using
"sharpie" follow these steps:
Open a Termimal (Command-line) session.
Change to the directory where "shared" is located.
Type:
sharpie bind --output=./SharpieOutput --namespace=Shared --sdk iphoseos15.5 -scope ./shared ./shared/build/xcode-frameworks/Debug/iphonesimulator15.5/shared.framework/Headers/shared.h
(please replace "iphoneos15.5" by the correct SDK and "Debug/iphonesimulator15.5" by the correct folder name)
You also can choose another namespace instead of "Shared". It will be specified in the ApiDefinitions.h.
If successful, a "ApiDefinitions.cs" will be in a new subfolder
"SharpieOutput".
VISUAL STUDIO / XAMARIN
Use Visual Studio 2019 or 2022 or higher.
Create a new Solution, say, "MyApp".
"MyApp" should contain four projects: "MyApp", "MyApp.Android",
"MyApp.iOS".
Here, we don't talk about "MyApp.Android".
Right-click on the solution name and add a "New Project". Choose "iOS - Library - Bindings Library". Its name may be "MyApp.iOS.Binding".
Replace the ApiDefinitions.cs by that that has been created in the precding step.
Add the "shared" library (created by XCode in one of the steps above) as a "Native Library".
Right-click on ApiDefinitions.cs and change "Build action" =
"ObjcBindingApiDefinition".
When you now open ApiDefinitions.cs, you'll probably see a lot of errors and marked lines. They may be handled as follows:
For the "[Verify]" attribute, please check here: https://learn.microsoft.com/en-us/xamarin/ios/platform/binding-swift/walkthrough#build-a-binding-library , section 5.
If "NativeHandle" creates a compiler error, please add at the top:
#if !NET
using NativeHandle=System.IntPtr;
#endif
You may remove "using" with the shared module ("using shared")
If you encounter errors like "Cannot declare instance members in a static class (CS0708) and "static classes cannot implement interfaces" (CS0714): try to comment out or remove the attribute "[Category]".
"[Unavailable (PlatformName.Swift)]" may be removed if yielding an error.
Handle typed classes resp. Interfaces with "<T>". For example, the "<T>" attribute should be added to some interfaces representing typed classes. In some cases special handling is necessary.
CS0246: In some cases, when an element cannot be found, an attribute "[BaseType(typeof(SharedBase))]" may help (assuming that the interface SharedBase is defined at the beginning of this file).
If, during a build run, there are warnings CS8767 ("… hides inherited member"), add the attribute [Override] above these members. For "New()", however, add "[New]" instead.
In case of linker errors MT5211 "Native linking failed, undefined Objective-C class …", add the attribute "[Protocol]" in front of the interface definition:
[BaseTye (typeof (NSObject))]
[Protocol]
public interface MyInterface { … }
Other compiler / linker errors (e.g. " … was built for newer iOS version (…) than being linked …" possibly can result in warnings after that.
The "MyApp" project contains all platform independent code. Those classes which contain platform dependent parts should be defined as interfaces.
"MyApp.Android" and "MyApp.iOS" should implement these interfaces. For "MyApp.iOS", "MyApp" and "MyApp.iOS.Binding" should be added as References. The classes implementing those interfaces now can use the interfaces defined in ApiDefinitions.h.
End of instructions.
I have posted the same question in another forum - https://learn.microsoft.com/en-us/answers/questions/875957/use-business-code-for-android-and-ios-written-in-k.html - and I have posted a possible answer, see the answer of Jul 19, 2022. Spoiler: yes, it is possible, but not directly, and it is complicated.
I got a git-server on my Raspberry Pi with gitweb as webinterface.
Its working so far.
Now I want to connect via Android Studio with the built-in ssh to it.
My project dir is :
/home/git/straff.git
I'll connect with this command from Android Studio:
:ssh:git#192.168.178.21:/straff
Android Studio is giving me this when I test the connection:
Cannot access /straff/CVSROOT
I am using password auth for it. I can access from command line tools to my repo...
Why Android Studio cant?
I can access from command line tools to my repo...
Why Android Studio cant?
Your error is you are trying to access 192.168.178.21:/straff which is /straff on that machine. Either provide the full path like below or use this one
:ssh:git#192.168.178.21:straff
Old post:
You can try to specify the full path to Android Studio:
:ssh:git#192.168.178.21:/home/git/straff
I am using password auth for it.
That means the ssh connection doesn't use a private/public (~/.ssh/id_rsa(.pub)) key.
A good tutorial to follow with Android Studio is the one titled "How to push to a remote Git repository over SSH with private/public key authentication using Android Studio".
Hmm, should the URL be like:
ssh://git#192.168.178.21/straff
I had problems with setting ssh key. I solved it by creating id_rsa -titled file under .ssh-directory (under user home-dir) and putting my RSA-stuff into it.
If you already have the remote git repository, which you want to check out, and you have a private key, then the instructions on https://www.londonappdeveloper.com/how-to-push-to-a-remote-git-repository-over-ssh-with-privatepublic-key-authentication-using-android-studio/ might help to some extent, but they are for older version of Android Studio and they are too complicated.
What you need to do (especially when you start from scratch) is:
Ensure that your key is an OpenSSH key, and that it's a private key (not a public key). This is where the above mentioned instructions are misleading - they point to the key in supposedly Putty format (the .ppk file), and this doesn't work. If you have a Putty key, use Putty's puttygen.exe tool to export the private key in OpenSSH format.
Create the config file as described in those instructions. I.e.
create the text file named config in .ssh subdirectory of your user directory. In my case the path would be C:\Users\Eugene.ssh\config.
Put the following to this file:
Host my-host.com
HostName my-host.com
Port 22
IdentityFile C:\Users\Eugene.ssh\my-private-key-for-my-host.openssh
(the original instructions include indentation of lines 2-4, but I couldn't add any indentation here).
Use Checkout Project From Version Control menu item in Android Studio's welcome screen to initiate GIT checkout.
Use the following settings during checkout (curly brackets contain the values which you replace with yours):
Git Repository URL: {projectalias}#{my-host.com}:base/{projectname}
Parent directory: eg. "z:\Projects" The path which must exist, and in which the new project is created
Project directory: eg. "myproject". The directory with this name will be created in Parent directory, so the files will be checked out to Parent_directory\Project_directory, eg. "z:\Projects\myproject".
Jenkins successfully create build for Android and then uploads to an S3 server. The build contains environment name, version number that is different for each build. These version number, environments are read from POM profiles. An example URL of s3 http://example.com/android/staging/ABC-Project-v0.1.58-staging-aligned.apk
I get the file name by this
cd $WORKSPACE/target/
FILE_NAME=$(echo *aligned.apk)
So my link will be http://example.com/dev/FILE_NAME
But this is only visible in shell script. I want to use this in an email template so that the Software test engineers can access it. I was looking for a way in which I can temporarily assign this value to a variable and then put that in the email template.
Email template is:
<html>
<body>
<h3>$PROJECT_NAME</h3>
<h4>Build #$BUILD_NUMBER - $BUILD_STATUS</h4>
<h4>${CAUSE}</h4>
<h4>$DEFAULT_CONTENT</h4>
<h4>Git Branch: ${GIT_BRANCH}</h4>
Changes since the last build:
${CHANGES}
</body>
</html>
Assuming that the email step is a later part of the Jenkins build process, you'll need to use the EnvInject plugin. From its own example use cases you can: inject variables as a build step obtained from a file filled in by a previous build step.
You could set these when parsing your POM (either in Maven directly, or you could parse it manually with something like a build step using the Groovy plugin and XmlSlurper (we do this actually)), and then they'd be available as environment variables (e.g. $CHANGES, $CAUSE etc) for your email templater script later on.
OK, I'm about to offer two things that are kind of ugly but working perfect:
In both you can put the output (the link you want) in a /tmp/job.output.tmp file and then:
use the post build task plugin - when the work ERROR or EXCEPTION or whatever you want is there, run sendEmail from bash to the people you want with the context of the file.
a little bash and everything is great.
this is probably more nice: use the https://wiki.jenkins-ci.org/display/JENKINS/Email-ext+plugin editable mail notification to send your users the console output / the file in zip / not zipped as you like when the build fails / stable again and such. They have so much options..
I have a Parse account that I'm using to store user data for my Android application. Because I'm using source control, I don't want to leave my secret key embedded in the code. Is there a way to have a "config" file that I would keep out of source control, that can then host the key? If that's not feasible, what are the best practices of handling such a situation?
Yes, you can create a folder outside of source control, put a file called app.properties in there, put your key in that properties file and add the folder to your build path. Then use a properties loader to load it from the classpath.
If you have many developers or more than one dev machine, you can set the local properties location as a variable in your build path so that each developer can configure their own.
One option is to put the key in an environment variable and then read it during your build.
in your pom.xml declare a property (secret.key)
<properties>
<secretKey>${env.SECRET_KEY}</secretKey>
<properties>
further down enable "filtering" on your resources
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
In resources maintain a "config.properties" to read with the variable ready for substitution:
secret_key=${secretKey}
Filtering in maven will replace ${secret.key} with the value from your environment variable.
If you are using gradle for your build with Android studio see section 16.6.6.2 on filtering files.
Within build.gradle add the following
import org.apache.tools.ant.filters.FixCrLfFilter
import org.apache.tools.ant.filters.ReplaceTokens
task copyProductionConfig(type: Copy) {
from 'source'
include 'config.properties'
into 'build/targetpath/config'
expand([
secretKey: System.getenv("SECRET_KEY")
])
}
In gradle you can also request input when you run gradlew using
Console console = System.console()
def password = console.readPassword("Enter Secret Key: ")
And then apply it to the appropriate config or source files.
I have an XML file that contains some config data for my Android App. In it there is config info that can be used for development and production. E.g. the link to our api can be set as follows:
For production:
<api>api.example.com</api>
For development:
<api>dev.example.com</api>
I keep this config file under /assets/app-config.xml
It is quite a hassle to keep having to remember which setting I have in the XML. Is there a way to automatically configure eclipse/ android so that it uses the production for runtime (export etc.) and the development when in debug mode.
Define multiple resources and use BuildConfig.DEBUG to conditionally get a resource or another:
<string name="url_api">api.example.com</string>
<string name="url_api_dev">dev.example.com</string>
When extracting the resource:
getString(BuildConfig.DEBUG ? R.string.url_api_dev : R.string.url_api);
This constant is set to true as long as you run from Eclipse. When you select the Export Signed Application Package option, it will be set to false.
If you use this method, it is a good idea to be aware of this bug.
Customize your build using ANT
Please refer the following link for more information
http://playaprogrammer.blogspot.com/2013/01/android-build-configuration-tutorial.html
I use this to create test and production builds from single source. You can have different configurations for development, QA, Production...